Search in sources :

Example 1 with CMAttributeDeclarationImpl

use of org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMAttributeDeclarationImpl 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)1 Path (org.eclipse.core.runtime.Path)1 CMAttributeDeclarationImpl (org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMAttributeDeclarationImpl)1 CMDocumentFactoryTLD (org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMDocumentFactoryTLD)1 CMElementDeclarationImpl (org.eclipse.jst.jsp.core.internal.contentmodel.tld.CMElementDeclarationImpl)1 ITaglibRecord (org.eclipse.jst.jsp.core.taglib.ITaglibRecord)1 CMDocument (org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)1 CMElementDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)1 CMNamedNodeMap (org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)1 CMNode (org.eclipse.wst.xml.core.internal.contentmodel.CMNode)1