Package org.jsurveylib

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


        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

*/
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

        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

        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

    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

        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

        assertFalse(cb.isCheckboxOnRight());
    }

    @Test
    public void alwaysAnswered() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\typecheckboxfiles\\alwaysanswered.xml")));
        CheckboxQuestion cb = (CheckboxQuestion) m.getQuestionByID("cb");
        //even though the checkbox is defined to be mandatory, that doesn't make sense so it should be ignored (mandatory is always false)
        assertTrue(cb.isMandatory());
        assertTrue(cb.isAnswered());    //checkboxes are always answered
    }
View Full Code Here

        assertTrue(cb.isAnswered());    //checkboxes are always answered
    }

    @Test
    public void dupe() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\typecheckboxfiles\\dupe.xml")));
        CheckboxQuestion orig = (CheckboxQuestion) m.getQuestionByID("cb");
        orig.addAnswerListener(this);
        orig.addEnableListener(this);
        orig.addValidationListener(this);
        orig.addVisibilityListener(this);
View Full Code Here

    private boolean enChanged = false;
    private boolean valChanged = false;

    @Test
    public void standard() throws Exception {
        Survey m = new Survey(new XMLSurveyReader(new File("src\\test\\org\\jsurveylib\\model\\question\\typemultichoicefiles\\standard.xml")));
        m.getQuestionByID("multi").addAnswerListener(this);
        RadioButtonsQuestion multi = (RadioButtonsQuestion) m.getQuestionByID("multi");
        Choice c1 = multi.getChoices().get(0);
        assertEquals("X", c1.getId());
        assertEquals("x", c1.getLabel());

        Choice c2 = multi.getChoices().get(1);
View Full Code Here

TOP

Related Classes of org.jsurveylib.Survey

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.