use of org.openforis.idm.metamodel.xml.SurveyIdmlBinder in project collect by openforis.
the class SurveyUnmarshaller method initSurvey.
protected void initSurvey() {
SurveyIdmlBinder surveyBinder = getSurveyBinder();
SurveyContext surveyContext = surveyBinder.getSurveyContext();
this.survey = surveyContext.createSurvey();
}
use of org.openforis.idm.metamodel.xml.SurveyIdmlBinder in project collect by openforis.
the class UIOptionsMigratorTest method setUp.
@Before
public void setUp() throws IdmlParseException {
SurveyIdmlBinder binder = new SurveyIdmlBinder(surveyContext);
binder.addApplicationOptionsBinder(new UIOptionsBinder());
InputStream is = ClassLoader.getSystemResourceAsStream("test.idm.xml");
survey = (CollectSurvey) binder.unmarshal(is);
uiOptions = survey.getUIOptions();
}
use of org.openforis.idm.metamodel.xml.SurveyIdmlBinder in project collect by openforis.
the class AbstractTest method setUp.
@BeforeClass
public static void setUp() throws IOException, XmlParseException, IdmlParseException {
URL idm = AbstractTest.class.getResource("/test.idm.xml");
InputStream is = idm.openStream();
SurveyIdmlBinder binder = new SurveyIdmlBinder(new CollectTestSurveyContext());
survey = (CollectSurvey) binder.unmarshal(is);
}
use of org.openforis.idm.metamodel.xml.SurveyIdmlBinder in project collect by openforis.
the class XmlBindingIntegrationTest method roundTripMarshallingTest.
// private Log log = LogFactory.getLog(XmlBindingIntegrationTest.class);
@Test
public void roundTripMarshallingTest() throws IdmlParseException, IOException {
URL idm = ClassLoader.getSystemResource("test.idm.xml");
InputStream is = idm.openStream();
SurveyContext ctx = new DefaultSurveyContext();
SurveyIdmlBinder binder = new SurveyIdmlBinder(ctx);
Survey survey = binder.unmarshal(is);
StringWriter sw = new StringWriter();
binder.marshal(survey, sw);
String idml2 = sw.toString();
StringReader sr = new StringReader(idml2);
Survey survey2 = binder.unmarshal(sr);
Assert.assertTrue(survey.deepEquals(survey2));
// TODO
new File("target/test/output").mkdirs();
FileOutputStream fos = new FileOutputStream("target/test/output/marshalled.idm.xml");
SurveyMarshaller sm = new SurveyMarshaller(binder);
// sm.setIndent(true);
sm.marshal(survey, fos, "UTF-8");
fos.flush();
fos.close();
}
use of org.openforis.idm.metamodel.xml.SurveyIdmlBinder in project collect by openforis.
the class AbstractTest method createTestSurvey.
protected static Survey createTestSurvey() throws IdmlParseException {
InputStream is = AbstractTest.class.getClassLoader().getResourceAsStream("test.idm.xml");
SurveyContext surveyContext = new TestSurveyContext();
SurveyIdmlBinder parser = new SurveyIdmlBinder(surveyContext);
Survey survey = parser.unmarshal(is);
return survey;
}
Aggregations