Package org.auraframework.impl.root.parser

Examples of org.auraframework.impl.root.parser.XMLParser


    public RegisterEventHandlerTest(String name) {
        super(name);
    }

    public void testSanity() throws Exception {
        XMLParser parser = XMLParser.getInstance();
        DefDescriptor<ComponentDef> descriptor = DefDescriptorImpl.getInstance("test:fakeparser", ComponentDef.class);
        StringSource<ComponentDef> source = new StringSource<>(
                descriptor,
                "<aura:component><aura:registerevent name='click' type='aura:click' description='The Description' access='global'/></aura:component>",
                "myID", Format.XML);
        ComponentDef def2 = parser.parse(descriptor, source);
        RegisterEventDef red = def2.getRegisterEventDefs().get("click");
        assertNotNull(red);
        assertEquals("click", red.getName());
        assertTrue(red.isGlobal());
    }
View Full Code Here


        assertEquals("click", red.getName());
        assertTrue(red.isGlobal());
    }

    public void testInvalidAccess() throws Exception {
        XMLParser parser = XMLParser.getInstance();
        DefDescriptor<ComponentDef> descriptor = DefDescriptorImpl.getInstance("test:fakeparser", ComponentDef.class);
        StringSource<ComponentDef> source = new StringSource<>(
                descriptor,
                "<aura:component><aura:registerevent name='aura:click' description='The Description' access='fakeAccessLevel'/></aura:component>",
                "myID", Format.XML);
        ComponentDef cd = parser.parse(descriptor, source);
        try {
            cd.validateDefinition();
            fail("Should have thrown AuraException because access level isn't public or global");
        } catch (InvalidDefinitionException e) {
View Full Code Here

        }
    }

    public void testTextContent() throws Exception {
        XMLParser parser = XMLParser.getInstance();
        DefDescriptor<ComponentDef> descriptor = DefDescriptorImpl.getInstance("test:fakeparser", ComponentDef.class);
        StringSource<ComponentDef> source = new StringSource<>(
                descriptor,
                "<aura:component><aura:registerevent name='aura:click' description='The Description' access='global'>invalidtext</aura:registerevent></aura:component>",
                "myID", Format.XML);
        ComponentDef cd = parser.parse(descriptor, source);
        try {
            cd.validateDefinition();
            fail("Should have thrown AuraException because text is between aura:registerevent tags");
        } catch (InvalidDefinitionException e) {
View Full Code Here

        }
    }

    public void testMissingType() throws Exception {
        XMLParser parser = XMLParser.getInstance();
        DefDescriptor<ComponentDef> descriptor = DefDescriptorImpl.getInstance("test:fakeparser", ComponentDef.class);
        StringSource<ComponentDef> source = new StringSource<>(
                descriptor,"<aura:component><aura:registerevent name='wheresthetype'/></aura:component>",
                "myID", Format.XML);
      ComponentDef def = parser.parse(descriptor, source);
        try {
          def.validateDefinition();
            fail("Missing type for event should be flagged");
        } catch (Exception e) {
          assertExceptionMessageEndsWith(e, InvalidDefinitionException.class, "type attribute is required on registerevent");
View Full Code Here

          assertExceptionMessageEndsWith(e, InvalidDefinitionException.class, "type attribute is required on registerevent");
        }
    }

    public void testMissingNameForComponentEvent() throws Exception {
        XMLParser parser = XMLParser.getInstance();
        DefDescriptor<EventDef> eventDesc = addSourceAutoCleanup(EventDef.class, "<aura:event type='COMPONENT'/>");
        DefDescriptor<ComponentDef> descriptor = DefDescriptorImpl.getInstance("test:fakeparser", ComponentDef.class);
        StringSource<ComponentDef> source = new StringSource<>(
                descriptor,
                String.format("<aura:component><aura:registerevent type='%s'/></aura:component>",eventDesc.getDescriptorName()),
                "myID", Format.XML);
      ComponentDef def = parser.parse(descriptor, source);
        try {
          def.validateDefinition();
            fail("Missing name for component event should be flagged");
        } catch (Exception e) {
          assertExceptionMessageEndsWith(e, InvalidDefinitionException.class, "name is a required attribute on tag registerevent");
View Full Code Here

          assertExceptionMessageEndsWith(e, InvalidDefinitionException.class, "name is a required attribute on tag registerevent");
        }
    }

    public void testMissingNameForApplicationEvent() throws Exception {
        XMLParser parser = XMLParser.getInstance();
        DefDescriptor<EventDef> eventDesc = addSourceAutoCleanup(EventDef.class, "<aura:event type='APPLICATION'/>");
        DefDescriptor<ComponentDef> descriptor = DefDescriptorImpl.getInstance("test:fakeparser", ComponentDef.class);
        StringSource<ComponentDef> source = new StringSource<>(
                descriptor,
                String.format("<aura:component><aura:registerevent type='%s'/></aura:component>",eventDesc.getDescriptorName()),
                "myID", Format.XML);
      ComponentDef def = parser.parse(descriptor, source);
        try {
          def.validateDefinition();
            fail("Missing name for application event should be flagged");
        } catch (Exception e) {
          assertExceptionMessageEndsWith(e, InvalidDefinitionException.class, "name is a required attribute on tag registerevent");
View Full Code Here

    public EventHandlerDefHandlerTest(String name) {
        super(name);
    }

    public void testEventHandlerDefHandler() throws Exception {
        XMLParser parser = XMLParser.getInstance();
        DefDescriptor<ComponentDef> descriptor = DefDescriptorImpl.getInstance("test:fakeparser", ComponentDef.class);
        StringSource<ComponentDef> source = new StringSource<>(descriptor,
                "<aura:component><aura:handler event='aura:click' action='{!c.action}'/></aura:component>", "myID",
                Format.XML);
        ComponentDef def = parser.parse(descriptor, source);
        assertNotNull(def);
    }
View Full Code Here

        ComponentDef def = parser.parse(descriptor, source);
        assertNotNull(def);
    }

    public void testRegisterDuplicateEventNames() throws Exception {
        XMLParser parser = XMLParser.getInstance();
        DefDescriptor<ComponentDef> descriptor = DefDescriptorImpl.getInstance("test:fakeparser", ComponentDef.class);
        StringSource<ComponentDef> source = new StringSource<>(descriptor, "<aura:component>"
                + "<aura:registerevent name='dupName' type='aura:click'/>"
                + "<aura:registerevent name='dupName' type='aura:click'/>" + "</aura:component>", "myID", Format.XML);
        ComponentDef cd = parser.parse(descriptor, source);
        try {
            cd.validateDefinition();
            fail("Should have thrown AuraRuntimeException for registering two events with the same name");
        } catch (Exception e) {
            checkExceptionContains(e, InvalidDefinitionException.class,
View Full Code Here

     * Events cannot be abstract
     *
     * @throws Exception
     */
    public void testAbstractEvent() throws Exception {
        XMLParser parser = XMLParser.getInstance();
        DefDescriptor<EventDef> descriptor = DefDescriptorImpl.getInstance("aura:testevent", EventDef.class);
        StringSource<EventDef> source = new StringSource<>(descriptor,
                "<aura:event type='component' abstract='true'></aura:event>", "myID", Format.XML);
        EventDef ed = parser.parse(descriptor, source);
        try {
            ed.validateDefinition();
            fail("Should have thrown AuraRuntimeException for creating an abstract event");
        } catch (Exception e) {
            checkExceptionContains(e, InvalidDefinitionException.class,
View Full Code Here

    public AttributeDefRefHandlerTest(String name) throws Exception {
        super(name);
    }

    public void testAttributeDefRefParsing() throws Exception {
        XMLParser parser = XMLParser.getInstance();
        DefDescriptor<ComponentDef> descriptor = DefDescriptorImpl.getInstance("test:fakeparser", ComponentDef.class);
        StringSource<ComponentDef> source = new StringSource<>(descriptor,
                "<aura:component><aura:set attribute='header' value='false'>Child Text</aura:set></aura:component>",
                "myID", Format.XML);
        ComponentDef cd = parser.parse(descriptor, source);
        assertNotNull(cd);
    }
View Full Code Here

TOP

Related Classes of org.auraframework.impl.root.parser.XMLParser

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.