use of org.sonar.plugins.openedge.foundation.OpenEdgeSettings in project sonar-openedge by Riverside-Software.
the class OpenEdgeSettingsTest method testSonarDatabasesFromSonarLint01.
@Test
public void testSonarDatabasesFromSonarLint01() throws Exception {
// Simple sports2000 database schema on SonarLint - This schema doesn't include table 'Benefits'
MapSettings settings = new MapSettings();
settings.setProperty(Constants.SLINT_DATABASES, new File(TestProjectSensorContext.BASEDIR, ".sonarlint/sp2k.schema").getAbsolutePath());
settings.setProperty("sonar.sources", "src");
SensorContextTester context = SensorContextTester.create(new File(TestProjectSensorContext.BASEDIR));
context.setSettings(settings);
OpenEdgeSettings oeSettings = new OpenEdgeSettings(context.config(), context.fileSystem(), OpenEdgePluginTest.SONARLINT_RUNTIME, OpenEdgePluginTest.SERVER);
IProparseEnvironment ppSess = oeSettings.getProparseSessions().getDefaultSession();
assertNotNull(ppSess);
assertNotNull(ppSess.getSchema());
assertNotNull(ppSess.getSchema().lookupDatabase("sp2k"));
assertNull(ppSess.getSchema().lookupDatabase("sp3k"));
assertNotNull(ppSess.getSchema().lookupTable("item"));
assertNotNull(ppSess.getSchema().lookupTable("sp2k", "item"));
assertNull(ppSess.getSchema().lookupTable("sp3k", "item"));
assertNull(ppSess.getSchema().lookupTable("benefits"));
}
use of org.sonar.plugins.openedge.foundation.OpenEdgeSettings in project sonar-openedge by Riverside-Software.
the class OpenEdgeWarningsSensorTest method testWarnings.
@Test
public void testWarnings() throws IOException {
SensorContextTester context = TestProjectSensorContext.createContext();
context.setActiveRules(createRules1());
OpenEdgeSettings oeSettings = new OpenEdgeSettings(context.config(), context.fileSystem(), OpenEdgePluginTest.SONARQUBE_RUNTIME, OpenEdgePluginTest.SERVER);
OpenEdgeWarningsSensor sensor = new OpenEdgeWarningsSensor(oeSettings);
sensor.execute(context);
// Case-sensitive, so one issue can't be reported
Assert.assertEquals(context.allIssues().size(), 4);
Iterator<Issue> issues = context.allIssues().iterator();
Issue issue;
// Starts with ../
issue = issues.next();
assertEquals(issue.primaryLocation().inputComponent().key(), TestProjectSensorContext.BASEDIR + ":" + TestProjectSensorContext.FILE4);
assertEquals(issue.primaryLocation().textRange().start().line(), 2);
issue = issues.next();
assertEquals(issue.primaryLocation().inputComponent().key(), TestProjectSensorContext.BASEDIR + ":" + TestProjectSensorContext.FILE4);
assertEquals(issue.primaryLocation().textRange().start().line(), 3);
assertEquals(issue.ruleKey(), RuleKey.of(Constants.STD_REPOSITORY_KEY, OpenEdgeRulesDefinition.COMPILER_WARNING_1688_RULEKEY));
issue = issues.next();
assertEquals(issue.primaryLocation().inputComponent().key(), TestProjectSensorContext.BASEDIR + ":" + TestProjectSensorContext.FILE4);
assertEquals(issue.primaryLocation().textRange().start().line(), 3);
assertTrue(issue.primaryLocation().message().endsWith("Another one (1689)"));
assertEquals(issue.ruleKey(), RuleKey.of(Constants.STD_REPOSITORY_KEY, OpenEdgeRulesDefinition.COMPILER_WARNING_RULEKEY));
issue = issues.next();
assertEquals(issue.primaryLocation().inputComponent().key(), TestProjectSensorContext.BASEDIR + ":" + TestProjectSensorContext.FILE1);
assertEquals(issue.primaryLocation().textRange().start().line(), 1);
// Verify that leading 'WARNING' is removed, as well as the message number
assertEquals(issue.primaryLocation().message(), "Program src\\procedures\\sample\\inc\\test.i, Line 1 is an expression statement that evaluates to a constant.");
}
use of org.sonar.plugins.openedge.foundation.OpenEdgeSettings in project sonar-openedge by Riverside-Software.
the class OpenEdgeCPDSensorTest method testCPDSensor.
@Test
public void testCPDSensor() throws Exception {
MapSettings settings = new MapSettings();
settings.setProperty(Constants.USE_SIMPLE_CPD, true);
SensorContextTester context = TestProjectSensorContext.createContext();
context.setSettings(settings);
OpenEdgeSettings oeSettings = new OpenEdgeSettings(context.config(), context.fileSystem(), OpenEdgePluginTest.SONARQUBE_RUNTIME, OpenEdgePluginTest.SERVER);
OpenEdgeCPDSensor sensor = new OpenEdgeCPDSensor(oeSettings);
sensor.execute(context);
assertNotNull(context.cpdTokens(BASEDIR + ":" + FILE3));
assertEquals(context.cpdTokens(BASEDIR + ":" + FILE3).size(), 14);
assertNotNull(context.cpdTokens(BASEDIR + ":" + CLASS1));
assertEquals(context.cpdTokens(BASEDIR + ":" + CLASS1).size(), 19);
assertNotNull(context.cpdTokens(BASEDIR + ":" + FILE4));
assertEquals(context.cpdTokens(BASEDIR + ":" + FILE4).size(), 3);
}
use of org.sonar.plugins.openedge.foundation.OpenEdgeSettings in project sonar-openedge by Riverside-Software.
the class OpenEdgeCodeColorizerTest method testSp2k.
@Test
public void testSp2k() throws Exception {
SensorContextTester context = TestProjectSensorContext.createContext();
OpenEdgeSettings oeSettings = new OpenEdgeSettings(context.config(), context.fileSystem(), OpenEdgePluginTest.SONARQUBE_RUNTIME, OpenEdgePluginTest.SERVER);
OpenEdgeCodeColorizer sensor = new OpenEdgeCodeColorizer(oeSettings);
sensor.execute(context);
// Comments
Assert.assertNotNull(context.highlightingTypeAt(BASEDIR + ":" + FILE1, 1, 10));
Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + FILE1, 1, 10).size(), 1);
Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + FILE1, 1, 10).get(0), TypeOfText.COMMENT);
// Quoted string
Assert.assertNotNull(context.highlightingTypeAt(BASEDIR + ":" + FILE2, 5, 13));
Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + FILE2, 5, 13).size(), 1);
Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + FILE2, 5, 13).get(0), TypeOfText.STRING);
// Keyword
Assert.assertNotNull(context.highlightingTypeAt(BASEDIR + ":" + FILE2, 5, 5));
Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + FILE2, 5, 5).size(), 1);
Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + FILE2, 5, 5).get(0), TypeOfText.KEYWORD);
// Preprocessor
Assert.assertNotNull(context.highlightingTypeAt(BASEDIR + ":" + FILE3, 3, 25));
Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + FILE3, 3, 25).size(), 1);
Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + FILE3, 3, 25).get(0), TypeOfText.PREPROCESS_DIRECTIVE);
Assert.assertNotNull(context.highlightingTypeAt(BASEDIR + ":" + FILE3, 4, 10));
Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + FILE3, 4, 10).size(), 1);
Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + FILE3, 4, 10).get(0), TypeOfText.STRING);
Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + FILE3, 4, 16).size(), 0);
// Constants
Assert.assertNotNull(context.highlightingTypeAt(BASEDIR + ":" + FILE3, 14, 9));
Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + FILE3, 14, 9).size(), 1);
Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + FILE3, 14, 9).get(0), TypeOfText.CONSTANT);
// Include file
Assert.assertNotNull(context.highlightingTypeAt(BASEDIR + ":" + FILE3, 21, 3));
Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + FILE3, 21, 3).size(), 1);
Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + FILE3, 21, 3).get(0), TypeOfText.PREPROCESS_DIRECTIVE);
Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + FILE3, 21, 20).size(), 1);
Assert.assertEquals(context.highlightingTypeAt(BASEDIR + ":" + FILE3, 21, 20).get(0), TypeOfText.PREPROCESS_DIRECTIVE);
}
use of org.sonar.plugins.openedge.foundation.OpenEdgeSettings in project sonar-openedge by Riverside-Software.
the class OpenEdgeProparseSensorTest method testPreprocessorSettings01.
@Test
public void testPreprocessorSettings01() throws Exception {
MapSettings settings = new MapSettings();
settings.setProperty("sonar.oe.preprocessor.window-system", "foobar");
settings.setProperty("sonar.oe.preprocessor.opsys", "unix");
settings.setProperty("sonar.oe.preprocessor.batch-mode", "false");
settings.setProperty("sonar.oe.preprocessor.process-architecture", "32");
settings.setProperty("sonar.oe.preprocessor.proversion", "12.0");
SensorContextTester context = TestProjectSensorContext.createContext();
context.setSettings(settings);
OpenEdgeSettings oeSettings = new OpenEdgeSettings(context.config(), context.fileSystem(), OpenEdgePluginTest.SONARQUBE_RUNTIME, OpenEdgePluginTest.SERVER);
assertFalse(oeSettings.getProparseSessions().getDefaultSession().getProparseSettings().getBatchMode());
assertEquals(oeSettings.getProparseSessions().getDefaultSession().getProparseSettings().getWindowSystem(), "foobar");
assertEquals(oeSettings.getProparseSessions().getDefaultSession().getProparseSettings().getOpSys(), OperatingSystem.UNIX);
assertEquals(oeSettings.getProparseSessions().getDefaultSession().getProparseSettings().getProcessArchitecture(), Integer.valueOf(32));
assertEquals(oeSettings.getProparseSessions().getDefaultSession().getProparseSettings().getProversion(), "12.0");
}
Aggregations