Package ro.isdc.wro.manager.factory

Examples of ro.isdc.wro.manager.factory.WroManagerFactory


  }

  @Test
  public void wroModelIsRetrievedCorrectly() {
    ServletContextAttributeHelper servletContextAttributeHelper = mock(ServletContextAttributeHelper.class);
    WroManagerFactory managerFactory = mock(WroManagerFactory.class);
    WroManager manager = PowerMockito.mock(WroManager.class);
    WroModelFactory modelFactory = mock(WroModelFactory.class);

    WroModel modelFromTest = new WroModel();

    when(servletContextAttributeHelper.getManagerFactory()).thenReturn(managerFactory);
    when(managerFactory.create()).thenReturn(manager);
    when(manager.getModelFactory()).thenReturn(modelFactory);
    when(modelFactory.create()).thenReturn(modelFromTest);

    WroTagLibConfig wroTagLibConfig = new WroTagLibConfig(this.servletContext);
    WroModel modelFromConfig = wroTagLibConfig.getModel(servletContextAttributeHelper);
View Full Code Here


   *
   * @return {@link WroManagerFactory} implementation.
   */
  protected WroManagerFactory getManagerFactory() {
    if (managerFactory == null) {
      WroManagerFactory localManagerFactory = null;
      try {
        localManagerFactory = newWroManagerFactory();
      } catch (final MojoExecutionException e) {
        throw WroRuntimeException.wrap(e);
      }
View Full Code Here

    final Properties properties = new Properties();
    properties.setProperty(ConfigurableProcessorsFactory.PARAM_POST_PROCESSORS, RhinoCoffeeScriptProcessor.ALIAS);
    filter.setProperties(properties);
    filter.init(mockFilterConfig);

    final WroManagerFactory factory = filter.newWroManagerFactory();
    final WroManager wroManager = factory.create();

    final ProcessorsFactory processorsFactory = wroManager.getProcessorsFactory();
    final Collection<ResourcePostProcessor> postProcessors = processorsFactory.getPostProcessors();

    assertEquals(1, postProcessors.size());
View Full Code Here

  /**
   * {@inheritDoc}
   */
  protected WroManagerFactory newWroManagerFactory()
      throws MojoExecutionException {
    WroManagerFactory factory = null;
    if (wroManagerFactory != null) {
      factory = createCustomManagerFactory();
    } else {
      factory = new ExtensionsStandaloneManagerFactory();
    }
    getLog().info("wroManagerFactory class: " + factory.getClass().getName());

    if (factory instanceof ExtraConfigFileAware) {
      if (extraConfigFile == null) {
        throw new MojoExecutionException("The " + factory.getClass() + " requires a valid extraConfigFile!");
      }
      getLog().debug("Using extraConfigFile: " + extraConfigFile.getAbsolutePath());
      ((ExtraConfigFileAware) factory).setExtraConfigFile(extraConfigFile);
    }
    return factory;
View Full Code Here

  /**
   * Creates an instance of Manager factory based on the value of the wroManagerFactory plugin parameter value.
   */
  private WroManagerFactory createCustomManagerFactory()
      throws MojoExecutionException {
    WroManagerFactory managerFactory;
    try {
      final Class<?> wroManagerFactoryClass = Thread.currentThread().getContextClassLoader().loadClass(
          wroManagerFactory.trim());
      managerFactory = (WroManagerFactory) wroManagerFactoryClass.newInstance();
    } catch (final Exception e) {
View Full Code Here

    final ThreadLocal<Exception> processorsCreationException = new ThreadLocal<Exception>();
    try {
      final ConfigurableWroFilter filter = new ConfigurableWroFilter() {
        @Override
        protected WroManagerFactory newWroManagerFactory() {
          final WroManagerFactory original = super.newWroManagerFactory();
          try {
            original.create().getProcessorsFactory().getPreProcessors();
          } catch (final Exception e) {
            LOG.debug("caught exception: ", e);
            processorsCreationException.set(e);
          }
          return original;
View Full Code Here

    victim = new ModelAsJsonRequestHandler();

    final WroModel wroModel = createSimpleModelStub();

    when(mockModelFactory.create()).thenReturn(wroModel);
    final WroManagerFactory managerFactory = new BaseWroManagerFactory().setModelFactory(mockModelFactory);
    final Injector injector = InjectorBuilder.create(managerFactory).build();
    injector.inject(victim);

    // Setup response writer
    outputStream = new ByteArrayOutputStream();
View Full Code Here

  @Test
  public void shouldNotProvideProxyUriForExternalResources()
      throws IOException {
    when(mockModelFactory.create()).thenReturn(createWroModelExternalModelStub());
    final WroManagerFactory managerFactory = new BaseWroManagerFactory().setModelFactory(mockModelFactory);
    victim = new ModelAsJsonRequestHandler();
    final Injector injector = InjectorBuilder.create(managerFactory).build();
    injector.inject(victim);

    victim.handle(mockRequest, mockResponse);
View Full Code Here

  @Before
  public void setUp() {
    initMocks(this);
    Context.set(Context.standaloneContext());
    victim = new DefaultCacheKeyFactory();
    final WroManagerFactory managerFactory = new BaseWroManagerFactory().setGroupExtractor(mockGroupExtractor);
    InjectorBuilder.create(managerFactory).build().inject(victim);
  }
View Full Code Here

  }

  @Test
  public void shouldLoadWroManagerFactoryFromServletContextAttribute() throws Exception {
    final WroFilter filter = new WroFilter();
    final WroManagerFactory expectedManagerFactory = new BaseWroManagerFactory();
    final ServletContextAttributeHelper helper = new ServletContextAttributeHelper(mockServletContext);
    Mockito.when(mockServletContext.getAttribute(helper.getAttributeName(Attribute.MANAGER_FACTORY))).thenReturn(expectedManagerFactory);
    //reset it because it was initialized in test setup.
    filter.setWroManagerFactory(null);
    filter.init(mockFilterConfig);
View Full Code Here

TOP

Related Classes of ro.isdc.wro.manager.factory.WroManagerFactory

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.