CommentUtil { public static void commentOrUncommentSQL(JTextArea scriptPanel) { commentOrUncomment(scriptPanel, SQL_COMMENT_CHARACTER); }  static void commentOrUncommentSQL(JTextArea scriptPanel); static void commentOrUncommentJava(JTextArea scriptPanel); static void commentOrUncommentR(JTextArea scriptPanel); static void blockCommentOrUncomment(JTextArea scriptPanel); static final String SQL_COMMENT_CHARACTER; static final String JAVA_COMMENT_CHARACTER; static final String R_COMMENT_CHARACTER; static final String BLOCK_COMMENT_START; static final String BLOCK_COMMENT_END; }
@Test public void testCommentLinesOneAndTwo() { org.junit.Assume.assumeTrue(!GraphicsEnvironment.isHeadless()); RSyntaxTextArea scriptPanel = new RSyntaxTextArea(); scriptPanel.setText(TEXT); scriptPanel.select(13, 226); CommentUtil.commentOrUncommentSQL(scriptPanel); assertEquals(CommentUtil.SQL_COMMENT_CHARACTER + LINE_ONE + CommentUtil.SQL_COMMENT_CHARACTER + LINE_TWO + LINE_THREE, scriptPanel.getText()); }
@Test public void testCommentUncommentLinesOneAndTwo() { org.junit.Assume.assumeTrue(!GraphicsEnvironment.isHeadless()); RSyntaxTextArea scriptPanel = new RSyntaxTextArea(); scriptPanel.setText(TEXT); scriptPanel.select(13, 226); CommentUtil.commentOrUncommentSQL(scriptPanel); CommentUtil.commentOrUncommentSQL(scriptPanel); assertEquals(TEXT, scriptPanel.getText()); }
@Test public void testUncommentUnbrokenRangeWithCommentRemainingOnLineTwo() { org.junit.Assume.assumeTrue(!GraphicsEnvironment.isHeadless()); RSyntaxTextArea scriptPanel = new RSyntaxTextArea(); scriptPanel.setText(CommentUtil.SQL_COMMENT_CHARACTER + LINE_ONE + CommentUtil.SQL_COMMENT_CHARACTER + CommentUtil.SQL_COMMENT_CHARACTER + LINE_TWO + CommentUtil.SQL_COMMENT_CHARACTER + LINE_THREE); scriptPanel.selectAll(); CommentUtil.commentOrUncommentSQL(scriptPanel); assertEquals(LINE_ONE + CommentUtil.SQL_COMMENT_CHARACTER + LINE_TWO + LINE_THREE, scriptPanel.getText()); }
@Test public void testCommentBrokenRangeWithNoCommentOnLineTwo() { org.junit.Assume.assumeTrue(!GraphicsEnvironment.isHeadless()); RSyntaxTextArea scriptPanel = new RSyntaxTextArea(); scriptPanel.setText(CommentUtil.SQL_COMMENT_CHARACTER + LINE_ONE + LINE_TWO + CommentUtil.SQL_COMMENT_CHARACTER + LINE_THREE); scriptPanel.selectAll(); CommentUtil.commentOrUncommentSQL(scriptPanel); assertEquals(CommentUtil.SQL_COMMENT_CHARACTER + CommentUtil.SQL_COMMENT_CHARACTER + LINE_ONE + CommentUtil.SQL_COMMENT_CHARACTER + LINE_TWO + CommentUtil.SQL_COMMENT_CHARACTER + CommentUtil.SQL_COMMENT_CHARACTER + LINE_THREE, scriptPanel.getText()); }