Examples of Survey


Examples of org.jsurveylib.Survey

    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

Examples of org.jsurveylib.Survey

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

        assertEquals(0, m.getCurrentPageNumber());
        l.linkClicked("page://1");
        assertEquals("page://1", url);
        assertEquals(1, m.getCurrentPageNumber());
        assertFalse(m.isLastPageAndComplete()); //a mandatory question is not answered

        l.linkClicked("page://0");
        assertEquals("page://0", url);
        assertEquals(0, m.getCurrentPageNumber());

        m.getQuestionByID("pageJump").getLabel().linkClicked("page://1");
        l.linkClicked("page://1");
        assertEquals("page://1", url);
    }
View Full Code Here

Examples of org.jsurveylib.Survey

        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

Examples of org.jsurveylib.Survey

    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());
        yesNo.setAnswer("yes");
        assertTrue(stateChanged);
View Full Code Here

Examples of org.jsurveylib.Survey

        assertEquals("no", yesNo.getAnswer());
    }

    @Test(expected = java.lang.IllegalArgumentException.class)
    public void notYesNo() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\typeyesnofiles\\notyesno.xml")));
        m.getQuestionByID("yesno").addAnswerListener(this);
        RadioButtonsQuestion yesNo = (RadioButtonsQuestion) m.getQuestionByID("yesno");
        yesNo.setAnswer("blah");
    }
View Full Code Here

Examples of org.jsurveylib.Survey

*/
public class XMLResultWriterTest {

    @Test
    public void saveXML() throws Exception {
        Survey survey = new Survey("src\\test\\org\\jsurveylib\\io\\xmlresultwriterfiles\\savexmlinput.xml");
        saveXMLTest(survey);
    }
View Full Code Here

Examples of org.jsurveylib.Survey

        saveXMLTest(survey);
    }

    @Test
    public void saveXMLReset() throws Exception {
        Survey survey = new Survey("src\\test\\org\\jsurveylib\\io\\xmlresultwriterfiles\\savexmlinput.xml");
        saveXMLTest(survey);
        survey.reset();
        saveXMLTest(survey);
    }
View Full Code Here

Examples of org.jsurveylib.Survey

        assertTrue(input.readLine().contains("<question>"));
    }

    @Test
    public void finalState() throws Exception {
        Survey survey = new Survey("src\\test\\org\\jsurveylib\\io\\xmlresultwriterfiles\\finalstate.xml");
        StringWriter stringWriter = new StringWriter();
        XMLResultWriter writer = new XMLResultWriter(stringWriter);
        writer.write(survey);

        String s = stringWriter.toString();
View Full Code Here

Examples of org.jsurveylib.Survey

    private boolean valChanged = false;


    @Test
    public void defaults() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\typecheckboxfiles\\defaults.xml")));
        m.getQuestionByID("cb").addAnswerListener(this);
        CheckboxQuestion cb = (CheckboxQuestion) m.getQuestionByID("cb");
        assertEquals("unchecked", cb.getAnswer())//it defaults to unchecked
        assertTrue(cb.isAnswered());
        assertFalse(cb.isChecked());
        cb.setAnswer("unchecked");       
        assertFalse(stateChanged);
View Full Code Here

Examples of org.jsurveylib.Survey

        assertTrue(cb.isCheckboxOnRight());
    }

    @Test
    public void noDefaults() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\typecheckboxfiles\\nodefaults.xml")));
        m.getQuestionByID("cb").addAnswerListener(this);
        CheckboxQuestion cb = (CheckboxQuestion) m.getQuestionByID("cb");
        assertTrue(cb.isAnswered());
        assertTrue(cb.isChecked());
        cb.setAnswer("checked");
        assertFalse(stateChanged);
        cb.setAnswer("unchecked");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.