use of org.csstudio.display.builder.model.CustomWidget in project org.csstudio.display.builder by kasemir.
the class PersistenceUnitTest method testWidgetWriting.
/**
* Writing widgets as XML
* @throws Exception on error
*/
@Test
public void testWidgetWriting() throws Exception {
final ByteArrayOutputStream stream = new ByteArrayOutputStream();
try (final ModelWriter writer = new ModelWriter(stream)) {
final Widget widget = new CustomWidget();
widget.setPropertyValue(propName, "Demo");
widget.getProperty(CustomWidget.propZeroTen).setValue(7);
writer.writeWidget(widget);
final GroupWidget group = new GroupWidget();
group.setPropertyValue(propName, "My Group");
final Widget child = new Widget("base");
child.setPropertyValue(propName, "Jänner");
group.runtimeChildren().addChild(child);
writer.writeWidget(group);
}
final String xml = stream.toString();
System.out.println(xml);
final String desired = getExampleFile();
assertThat(xml.replace("\r", ""), equalTo(desired));
}
Aggregations