Package org.jsurveylib.io

Examples of org.jsurveylib.io.XMLSurveyReader


    }

    @Test
    public void complexExpression() throws Exception {
        //<visibility expression="(multichoice == 'two' OR checkbox != 'checked' OR textfield == 'hi') AND filechooser == 'some/file'"/>
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\enablehandlerfiles\\complexexpression.xml")));

        assertFalse(model.getQuestionByID("withparens").isEnabled());
        model.setAnswer("multichoice", "two");
        model.setAnswer("checkbox", "unchecked");
        model.setAnswer("textfield", "hi");
View Full Code Here


        assertTrue(model.getQuestionByID("withoutparens").isEnabled());
    }

    @Test
    public void variables() throws Exception {
        Survey model = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\script\\enablehandlerfiles\\variables.xml")));
        model.getQuestionByID("variableusage").addEnableListener(this);
        assertFalse(enableStateChanged);
        model.setAnswer("textfield", "4");
        assertTrue(enableStateChanged);
        assertTrue(model.getQuestionByID("variableusage").isEnabled());
View Full Code Here

        assertFalse(m.hasSaveAs());
    }

    @Test
    public void useAll() throws Exception {
        Survey s = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\menufiles\\useall.xml")));
        Menu m = s.getMenu();
        assertTrue(m.exists());
        assertTrue(m.hasFirstPage());
        assertTrue(m.hasLastPage());
        assertTrue(m.hasNextPage());
View Full Code Here

        assertTrue(m.hasSaveAs());
    }

    @Test
    public void justMenu() throws Exception {
        Survey s = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\menufiles\\justmenu.xml")));
        Menu m = s.getMenu();
        assertTrue(m.exists());
        assertFalse(m.hasNextPage());
        assertFalse(m.hasOpen());
        assertFalse(m.hasPreviousPage());
View Full Code Here

    private boolean stateChanged = false;

    @Test
    public void defaults() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\typeinvisiblefiles\\defaults.xml")));
        m.getQuestionByID("invisible").addAnswerListener(this);
        FreeTextQuestion invisible = (FreeTextQuestion) m.getQuestionByID("invisible");
        assertFalse(invisible.isAnswerable());    //it's invisible so this method returns false
        assertFalse(stateChanged);
        invisible.setAnswer("blah");
View Full Code Here

        assertFalse(invisible.isAnswerable());    //it's invisible so this method returns false
    }

    @Test
    public void defaultSet() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\typeinvisiblefiles\\defaultset.xml")));
        m.getQuestionByID("invisible").addAnswerListener(this);
        FreeTextQuestion invisible = (FreeTextQuestion) m.getQuestionByID("invisible");
        assertTrue(invisible.isAnswered())//it's invisible so this method returns true
        assertEquals("hah", invisible.getAnswer());
        assertFalse(stateChanged);
View Full Code Here

    private String url;

    @Test
    public void cdata() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\labelfiles\\cdata.xml")));
        Label l = (Label) m.getCurrentPage().getSurveyElements().get(0);
        assertEquals("There is a \"visibility script\" on this page that is making a checkbox invisible right now.  To make the checkbox visible, type the magic word into this text field. The magic word is <b>please</b>", l.getText());
    }
View Full Code Here

        assertEquals("There is a \"visibility script\" on this page that is making a checkbox invisible right now.  To make the checkbox visible, type the magic word into this text field. The magic word is <b>please</b>", l.getText());
    }

    @Test
    public void linkClicked() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\labelfiles\\linkclicked.xml")));
        Label l = (Label) m.getCurrentPage().getSurveyElements().get(0);
        l.addLinkListener(this);
        assertNull(url);
        l.linkClicked("blah");
        assertEquals("blah", url);
View Full Code Here

        assertEquals("page://1", url);
    }

    @Test(expected = java.lang.IndexOutOfBoundsException.class)
    public void badPageLink() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\labelfiles\\badpagelink.xml")));
        Label l = (Label) m.getCurrentPage().getSurveyElements().get(0);
        l.linkClicked("page://2");
    }
View Full Code Here

    private boolean stateChanged = false;

    @Test
    public void defaults() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\typeyesnofiles\\defaults.xml")));
        m.getQuestionByID("yesno").addAnswerListener(this);
        RadioButtonsQuestion yesNo = (RadioButtonsQuestion) m.getQuestionByID("yesno");
        assertFalse(yesNo.isAnswered());
        assertFalse(stateChanged);
        assertEquals("", yesNo.getAnswer());
View Full Code Here

TOP

Related Classes of org.jsurveylib.io.XMLSurveyReader

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.