@Test
public void testBlockComment() throws BadLocationException {

    org.junit.Assume.assumeTrue(!GraphicsEnvironment.isHeadless());
    RSyntaxTextArea scriptPanel = new RSyntaxTextArea();
    scriptPanel.setText(TEXT);
    scriptPanel.select(13, 226);
    final String beforeSelection = scriptPanel.getText(0, scriptPanel.getSelectionStart());
    final String selection = scriptPanel.getText(
            scriptPanel.getSelectionStart(), scriptPanel.getSelectedText().length());
    final String afterSelection = scriptPanel.getText(
            scriptPanel.getSelectionEnd(),
            scriptPanel.getDocument().getEndPosition().getOffset() -  scriptPanel.getSelectionEnd() - 1);
    final String expectedText = beforeSelection
            + CommentUtil.BLOCK_COMMENT_START + selection + CommentUtil.BLOCK_COMMENT_END
            + afterSelection;
    // Block comment the selection
    CommentUtil.blockCommentOrUncomment(scriptPanel);
    assertEquals(expectedText, scriptPanel.getText());
    // Check that the commented part is selected.
    assertEquals(13, scriptPanel.getSelectionStart());
    assertEquals(226 + CommentUtil.BLOCK_COMMENT_START.length()
            + CommentUtil.BLOCK_COMMENT_END.length(),
            scriptPanel.getSelectionEnd());
}