Package ro.isdc.wro.model

Examples of ro.isdc.wro.model.WroModel


    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);

    assertEquals("Should return the available model", modelFromTest, modelFromConfig);
  }
View Full Code Here


  @Test
  public void instanceIsAvailableWhenInstanceCreatedAndModelAvailable() {
    when(this.wroTagLibConfig.getModel(
        Matchers.<ServletContextAttributeHelper>anyObject())
    ).thenReturn(new WroModel());

    WroConfig.createInstance(this.wroTagLibConfig);

    assertNotNull("The wro configuration retrieved is null", WroConfig.getInstance());
  }
View Full Code Here

        testGroup.get(ResourceType.CSS).size(),
        is(1));
  }

  private WroModel getModel() {
    WroModel model = new WroModel();
    Group group = new Group(TEST_GROUP);
    Resource js1 = Resource.create("a", ResourceType.JS);
    Resource js2 = Resource.create("b", ResourceType.JS);
    Resource css1 = Resource.create("c", ResourceType.CSS);

    group.setResources(Arrays.asList(js1, js2, css1));
    model.setGroups(Arrays.asList(group));

    return model;
  }
View Full Code Here

    }
    return instance;
  }

  private void loadConfig() throws ConfigurationException {
    WroModel model = this.wroTagLibConfig.getModel(
            this.wroTagLibConfig.getServletContextAttributeHelper()
        );
   
    groups = new HashMap<String, FilesGroup>();
   
    for (Group group: model.getGroups()) {
      String groupName = group.getName();
      FilesGroup filesGroup = new FilesGroup(groupName, new GroupLoader(instance.wroTagLibConfig, group));
      groups.put(groupName, filesGroup);
    }
  }
View Full Code Here

                _geonetworkRootDirectory = findGeonetworkRootDirectory(sourcesXmlFile);
            }
            FileInputStream sourcesInputStream = null;
            try {
                sourcesInputStream = new FileInputStream(sourcesXmlFile);
                final WroModel model = createModel(sourcesXmlFile, sourcesInputStream);
                logModel(model);
                return model;
            } finally {
                if (sourcesInputStream != null) {
                    IOUtils.closeQuietly(sourcesInputStream);
View Full Code Here

            SAXException, IOException {
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        Document doc = dBuilder.parse(sourcesXmlFile);

        final WroModel model = new WroModel();

        Group closureDepsGroup = new Group(GROUP_NAME_CLOSURE_DEPS);

        final NodeList includeNodes = doc.getElementsByTagName(INCLUDE_EL);

        for (int i = 0; i < includeNodes.getLength(); i++) {
            Element include = (Element) includeNodes.item(i);
            if (!include.hasAttribute(FILE_ATT)) {
                throw new AssertionError("include elements must have a " + FILE_ATT + " attribute");
            }

            Collection<IncludesStream> streams = null;
            try {
                streams = openIncludesStream(parentSourcesXmlFile, include.getAttribute(FILE_ATT));
                for (IncludesStream is : streams) {
                    InputStream stream = is.stream;
                    WroModel includedModel = createModel(is.locationLoadedFrom, stream);
                    for (Group group : includedModel.getGroups()) {
                        if (GROUP_NAME_CLOSURE_DEPS.equals(group.getName())) {
                            for (Resource resource : group.getResources()) {
                                closureDepsGroup.addResource(resource);
                            }
                        } else {
View Full Code Here

                            "<" + CSS_SOURCE_EL + " " +
                            WEBAPP_ATT + "=\"\" " +
                            PATH_ON_DISK_ATT + "=\"" + PATH_TO_ROOT_OF_TEST_RESOURCES + "\"/>" +
                            "</" + REQUIRE_EL + "></sources>";

        final WroModel wroModel = createRequireModel(sourcesXml);
        assertRequireModel(wroModel, false);
    }
View Full Code Here

    @Test
    public void testCreateUsingRequireAndGroupHasPathOnDisk() throws Exception {

        String sourcesXml = createSourcesXmlWithPathOnGroup();

        final WroModel wroModel = createRequireModel(sourcesXml);
        assertRequireModel(wroModel);
    }
View Full Code Here

    @Test
    public void testPathOnDiskIsFullPath() throws Exception {

        String sourcesXml = createSourcesXmlWithPathOnGroup(ClosureRequireDependencyManagerTest.getJsTestBaseDir().getAbsolutePath());

        final WroModel wroModel = createRequireModel(sourcesXml);
        assertRequireModel(wroModel);
    }
View Full Code Here

    public void testClosureJsGroup() throws Exception {

        final String jsTestBaseDir = ClosureRequireDependencyManagerTest.getJsTestBaseDir().getAbsolutePath();
        String sourcesXml = createSourcesXmlWithPathOnGroup(jsTestBaseDir);

        final WroModel wroModel = createRequireModel(sourcesXml);

        final Collection<Group> groups = wroModel.getGroups();

        Group depsGroup = null;
        for (Group group : groups) {
            if (group.getName().equals(GeonetWroModelFactory.GROUP_NAME_CLOSURE_DEPS)) {
                assertNull("There should only be one deps group but found at least 2", depsGroup);
View Full Code Here

TOP

Related Classes of ro.isdc.wro.model.WroModel

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.