Search in sources :

Example 1 with CMDocumentFactoryTLD

use of org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMDocumentFactoryTLD in project webtools.sourceediting by eclipse.

the class TestTaglibCMTests method testDynamicAttributes.

public void testDynamicAttributes() throws Exception {
    final String testName = "testDynamicAttributes";
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(testName);
    if (!project.exists()) {
        project = BundleResourceUtil.createSimpleProject(testName, null, null);
        BundleResourceUtil.copyBundleEntriesIntoWorkspace(TESTFILES_PATHSTRING + "testDynamicAttributes", "/testDynamicAttributes");
    }
    project.refreshLocal(IResource.DEPTH_INFINITE, null);
    CMDocumentFactoryTLD factory = new CMDocumentFactoryTLD();
    ITaglibRecord[] records = TaglibIndex.getAvailableTaglibRecords(new Path("/" + testName + "/"));
    assertEquals("There should only be one taglib record", 1, records.length);
    CMDocument document = factory.createCMDocument(records[0]);
    CMNamedNodeMap elements = document.getElements();
    assertNotNull("No elements for the CM Document", elements);
    CMNode node = elements.getNamedItem("bar");
    assertTrue("Node must be a CMElementDeclarationImpl", node instanceof CMElementDeclarationImpl);
    assertEquals("Dynamic attributes must be set to 'true'", "true", ((CMElementDeclarationImpl) node).getDynamicAttributes());
}
Also used : Path(org.eclipse.core.runtime.Path) CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) ITaglibRecord(org.eclipse.jst.jsp.core.taglib.ITaglibRecord) CMElementDeclarationImpl(org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMElementDeclarationImpl) CMNode(org.eclipse.wst.xml.core.internal.contentmodel.CMNode) CMDocumentFactoryTLD(org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMDocumentFactoryTLD) CMNamedNodeMap(org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap) IProject(org.eclipse.core.resources.IProject)

Example 2 with CMDocumentFactoryTLD

use of org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMDocumentFactoryTLD in project webtools.sourceediting by eclipse.

the class TestTaglibCMTests method testTagRuntimeExpressionValues.

public void testTagRuntimeExpressionValues() throws Exception {
    final String testName = "testLoadTagFiles";
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(testName);
    if (!project.exists()) {
        project = BundleResourceUtil.createSimpleProject(testName, null, null);
        BundleResourceUtil.copyBundleEntriesIntoWorkspace(TESTFILES_PATHSTRING + testName, "/" + testName);
    }
    project.refreshLocal(IResource.DEPTH_INFINITE, null);
    CMDocumentFactoryTLD factory = new CMDocumentFactoryTLD();
    ITaglibRecord[] records = TaglibIndex.getAvailableTaglibRecords(new Path("/" + testName + "/"));
    assertEquals("There should only be one taglib record", 1, records.length);
    CMDocument document = factory.createCMDocument(records[0]);
    CMNamedNodeMap elements = document.getElements();
    assertNotNull("No elements for the CM Document", elements);
    CMNode node = elements.getNamedItem("test");
    assertTrue("Node must be a CMElementDeclarationImpl", node instanceof CMElementDeclarationImpl);
    CMNamedNodeMap attributes = ((CMElementDeclaration) node).getAttributes();
    assertNotNull("No attributes", attributes);
    node = attributes.getNamedItem("myAttr");
    assertTrue("Node must be a CMAttributeDeclarationImpl", node instanceof CMAttributeDeclarationImpl);
    assertEquals("Default rtexprvalue for tags should be true", JSP11Namespace.ATTR_VALUE_TRUE, ((CMAttributeDeclarationImpl) node).getRtexprvalue());
    node = attributes.getNamedItem("noRuntimeAttr");
    assertTrue("Node must be a CMAttributeDeclarationImpl", node instanceof CMAttributeDeclarationImpl);
    assertEquals("rtexprvalue for should be false since explicitly set", JSP11Namespace.ATTR_VALUE_FALSE, ((CMAttributeDeclarationImpl) node).getRtexprvalue());
}
Also used : Path(org.eclipse.core.runtime.Path) CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) CMAttributeDeclarationImpl(org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMAttributeDeclarationImpl) CMElementDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration) ITaglibRecord(org.eclipse.jst.jsp.core.taglib.ITaglibRecord) CMElementDeclarationImpl(org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMElementDeclarationImpl) CMNode(org.eclipse.wst.xml.core.internal.contentmodel.CMNode) CMDocumentFactoryTLD(org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMDocumentFactoryTLD) CMNamedNodeMap(org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap) IProject(org.eclipse.core.resources.IProject)

Aggregations

IProject (org.eclipse.core.resources.IProject)2 Path (org.eclipse.core.runtime.Path)2 CMDocumentFactoryTLD (org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMDocumentFactoryTLD)2 CMElementDeclarationImpl (org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMElementDeclarationImpl)2 ITaglibRecord (org.eclipse.jst.jsp.core.taglib.ITaglibRecord)2 CMDocument (org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)2 CMNamedNodeMap (org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)2 CMNode (org.eclipse.wst.xml.core.internal.contentmodel.CMNode)2 CMAttributeDeclarationImpl (org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMAttributeDeclarationImpl)1 CMElementDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)1