SonarComponents { public List<File> getJspClasspath() { List<File> jspClasspath = new ArrayList<>(); jspClasspath.add(findPluginJar()); jspClasspath.addAll(getJavaClasspath()); return jspClasspath; } SonarComponents(FileLinesContextFactory fileLinesContextFactory, FileSystem fs,
                         JavaClasspath javaClasspath, JavaTestClasspath javaTestClasspath,
                         CheckFactory checkFactory, SonarJavaIssueFilter postAnalysisIssueFilter);  SonarComponents(FileLinesContextFactory fileLinesContextFactory, FileSystem fs,
                         JavaClasspath javaClasspath, JavaTestClasspath javaTestClasspath, CheckFactory checkFactory,
                         @Nullable CheckRegistrar[] checkRegistrars, SonarJavaIssueFilter postAnalysisIssueFilter);  SonarComponents(FileLinesContextFactory fileLinesContextFactory, FileSystem fs,
                         JavaClasspath javaClasspath, JavaTestClasspath javaTestClasspath, CheckFactory checkFactory,
                         @Nullable ProjectDefinition projectDefinition, SonarJavaIssueFilter postAnalysisIssueFilter);  SonarComponents(FileLinesContextFactory fileLinesContextFactory, FileSystem fs,
                         JavaClasspath javaClasspath, JavaTestClasspath javaTestClasspath, CheckFactory checkFactory,
                         @Nullable CheckRegistrar[] checkRegistrars, @Nullable ProjectDefinition projectDefinition,
                         SonarJavaIssueFilter postAnalysisIssueFilter); void setSensorContext(SensorContext context); FileLinesContext fileLinesContextFor(InputFile inputFile); NewSymbolTable symbolizableFor(InputFile inputFile); NewHighlighting highlightableFor(InputFile inputFile); List<File> getJavaClasspath(); List<File> getJavaTestClasspath(); List<File> getJspClasspath(); void registerCheckClasses(String repositoryKey, Iterable<Class<? extends JavaCheck>> checkClasses); JavaCheck[] checkClasses(); Iterable<Checks<JavaCheck>> checks(); void registerTestCheckClasses(String repositoryKey, Iterable<Class<? extends JavaCheck>> checkClasses); Collection<JavaCheck> testCheckClasses(); List<JavaCheck> jspCodeVisitors(); RuleKey getRuleKey(JavaCheck check); void addIssue(InputComponent inputComponent, JavaCheck check, int line, String message, @Nullable Integer cost); void reportIssue(AnalyzerMessage analyzerMessage); boolean reportAnalysisError(RecognitionException re, InputFile inputFile); boolean isSonarLintContext(); List<String> fileLines(InputFile inputFile); String inputFileContents(InputFile inputFile); boolean analysisCancelled(); boolean shouldFailAnalysisOnException(); File workDir(); InputComponent project(); static final String FAIL_ON_EXCEPTION_KEY; }
@Test void jsp_classpath_should_include_plugin() throws Exception { SensorContextTester sensorContextTester = SensorContextTester.create(new File("")); DefaultFileSystem fs = sensorContextTester.fileSystem(); JavaClasspath javaClasspath = mock(JavaClasspath.class); File someJar = new File("some.jar"); when(javaClasspath.getElements()).thenReturn(Collections.singletonList(someJar)); File plugin = new File("target/classes"); SonarComponents sonarComponents = new SonarComponents(fileLinesContextFactory, fs, javaClasspath, mock(JavaTestClasspath.class), checkFactory, null); List<String> jspClassPath = sonarComponents.getJspClasspath().stream().map(File::getAbsolutePath).collect(Collectors.toList()); assertThat(jspClassPath).containsExactly(plugin.getAbsolutePath(), someJar.getAbsolutePath()); }