public class SpanTest {
@Test
public void testSpan() {
try {
TextDocument doc = TextDocument.newTextDocument();
doc.addParagraph("This is a test paragraph!");
TextNavigation navigation = new TextNavigation("test", doc);
TextSelection sel = (TextSelection) navigation.nextSelection();
Span span = Span.newSpan(sel);
TextHyperlink link = span.applyHyperlink(new URI("http://www.ibm.com"));
DefaultStyleHandler handler = span.getStyleHandler();
Font font1Base = new Font("Arial", FontStyle.ITALIC, 10, Color.BLACK, TextLinePosition.THROUGH);
handler.getTextPropertiesForWrite().setFont(font1Base);
doc.save(ResourceUtilities.newTestOutputFile("spantest.odt"));
String content = span.getTextContent();
Assert.assertEquals("test", content);
span.setTextContent("new test");
Assert.assertEquals("new test", span.getTextContent());
doc.save(ResourceUtilities.newTestOutputFile("spantest.odt"));
} catch (Exception e) {
Logger.getLogger(SpanTest.class.getName()).log(Level.SEVERE, null, e);
Assert.fail();
}