List of usage examples for org.apache.commons.io IOUtils LINE_SEPARATOR_WINDOWS
String LINE_SEPARATOR_WINDOWS
To view the source code for org.apache.commons.io IOUtils LINE_SEPARATOR_WINDOWS.
Click Source Link
From source file:org.sonar.plugins.plsqltoad.PlSqlToadPage.java
private static String getActiveRulesXml(List<ActiveRule> activeRules) { StringBuilder sb = new StringBuilder(); for (ActiveRule activeRule : activeRules) { String toadKey = PlSqlToadRuleHelper.getToadKey(activeRule); if (toadKey != null) { sb.append(" <RULE rid=\""); sb.append(toadKey);/*from w w w . ja v a 2 s . c o m*/ sb.append("\" />"); sb.append(IOUtils.LINE_SEPARATOR_WINDOWS); } } return sb.toString(); }
From source file:org.sonar.plugins.plsqltoad.PlSqlToadPage.java
private File generateIniFile(File rst) { String template = getTemplate("/org/sonar/plsql/toad/plugin/CodeXpert-" + (pluginConf.hasToad10Credentials() ? "w" : "wo") + "-credentials.ini.template"); template = StringUtils.replace(template, "$rulesetName", profile.getName()); template = StringUtils.replace(template, "$ruleset", getPath(rst)); template = StringUtils.replace(template, "$outputDir", getPath(pluginConf.getToadOutputDirectory())); template = StringUtils.replace(template, "$page", String.valueOf(page)); template = StringUtils.replace(template, "$login", pluginConf.getToad10Login()); template = StringUtils.replace(template, "$password", pluginConf.getToad10Password()); StringBuilder filesToAnalyze = new StringBuilder(); int i = 1;/*from ww w . j a v a 2 s . c om*/ for (File file : files) { filesToAnalyze.append("FILE").append(i++).append("=").append(getPath(file)) .append(IOUtils.LINE_SEPARATOR_WINDOWS); } template = StringUtils.replace(template, "$files", filesToAnalyze.toString()); File ini = new File(pluginConf.getToadOutputDirectory(), "CodeXpert-" + page + ".ini"); saveToFile(ini, template); return ini; }
From source file:org.sonar.plugins.plsqltoad.PlSqlToadPageTest.java
@Test public void generateIniWithCredentialsTest() throws IOException { when(pluginConf.hasToad10Credentials()).thenReturn(true); File file1 = new File("file1.sql"); File file2 = new File("file2.sql"); PlSqlToadPage page = new PlSqlToadPage(new File[] { file1, file2 }, pluginConf, profile, 8); page.generate();//w w w. jav a 2s. c om InputStream in = getClass().getResourceAsStream("/PlSqlToadPage/WithCredentialsTestIni.ini"); try { String expected = IOUtils.toString(in); // Inject the canonical paths into the expected ini file expected = StringUtils.replace(expected, "$ruleset", PlSqlToadPage.getPath(new File(pluginConf.getToadOutputDirectory(), "Sonar-8.rst"))); expected = StringUtils.replace(expected, "$outputDir", PlSqlToadPage.getPath(pluginConf.getToadOutputDirectory())); expected = StringUtils.replace(expected, "$files", "FILE1=" + PlSqlToadPage.getPath(file1) + IOUtils.LINE_SEPARATOR_WINDOWS + "FILE2=" + PlSqlToadPage.getPath(file2) + IOUtils.LINE_SEPARATOR_WINDOWS); String actual = FileUtils.readFileToString(page.getIniFile()); assertThat(actual, is(expected)); } finally { IOUtils.closeQuietly(in); } }
From source file:org.sonar.plugins.plsqltoad.PlSqlToadPageTest.java
@Test public void generateIniWithoutCredentialsTest() throws IOException { when(pluginConf.hasToad10Credentials()).thenReturn(false); File file1 = new File("file1.sql"); File file2 = new File("file2.sql"); PlSqlToadPage page = new PlSqlToadPage(new File[] { file1, file2 }, pluginConf, profile, 8); page.generate();/* w w w . jav a2 s .c o m*/ InputStream in = getClass().getResourceAsStream("/PlSqlToadPage/WithoutCredentialsTestIni.ini"); try { String expected = IOUtils.toString(in); // Inject the canonical paths into the expected ini file expected = StringUtils.replace(expected, "$ruleset", PlSqlToadPage.getPath(new File(pluginConf.getToadOutputDirectory(), "Sonar-8.rst"))); expected = StringUtils.replace(expected, "$outputDir", PlSqlToadPage.getPath(pluginConf.getToadOutputDirectory())); expected = StringUtils.replace(expected, "$files", "FILE1=" + PlSqlToadPage.getPath(file1) + IOUtils.LINE_SEPARATOR_WINDOWS + "FILE2=" + PlSqlToadPage.getPath(file2) + IOUtils.LINE_SEPARATOR_WINDOWS); String actual = FileUtils.readFileToString(page.getIniFile()); assertThat(actual, is(expected)); } finally { IOUtils.closeQuietly(in); } }
From source file:org.sonar.plugins.plsqltoad.PlSqlToadRulesRepositoryTest.java
@Test public void createRulesSpecificRuleTest() { String key = "4201"; for (Rule rule : rules) { if (rule.getKey().equals(key)) { assertThat(rule.getName(), is("IF - Limit a CASE statement or expression to 128 choices")); assertThat(/*w ww .j av a 2 s.c o m*/ rule.getDescription().replace(IOUtils.LINE_SEPARATOR_WINDOWS, " ") .replace(IOUtils.LINE_SEPARATOR_UNIX, " "), is("<p>Although not enforced by Oracle it is a good idea to limit the number of choices to avoid performance penalties.</p>")); assertThat(rule.getSeverity(), is(RulePriority.BLOCKER)); return; } } throw new IllegalArgumentException("Unable to find a rule with " + key + " as key in the repository!"); }