File tree Expand file tree Collapse file tree
java-checks-test-sources/default/src/main/java/checks/spring/s4605
springBootApplication/app
java-checks/src/test/java/org/sonar/java/checks/spring Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package checks .spring .s4605 .mixed .app1 ;
2+
3+ import org .springframework .boot .SpringApplication ;
4+ import org .springframework .boot .autoconfigure .SpringBootApplication ;
5+ import org .springframework .context .annotation .ComponentScan ;
6+ import org .springframework .context .annotation .FilterType ;
7+
8+ @ SpringBootApplication
9+ @ ComponentScan (excludeFilters = {@ ComponentScan .Filter (type = FilterType .REGEX , pattern = "checks.spring.s4605.mixed.app1.smth" )})
10+ public class App1 {
11+ static void main (String [] args ) {
12+ SpringApplication .run (checks .spring .s4605 .springBootApplication .app .SpringBootApp1 .class , args );
13+ }
14+ }
Original file line number Diff line number Diff line change 1+ package checks .spring .s4605 .mixed .app1 .visible ;
2+
3+ import org .springframework .stereotype .Component ;
4+
5+ interface VisibleServiceI {
6+ }
7+
8+ @ Component
9+ public class VisibleService implements VisibleServiceI { // Compliant
10+ }
Original file line number Diff line number Diff line change 22
33import org .springframework .boot .SpringApplication ;
44import org .springframework .boot .autoconfigure .SpringBootApplication ;
5- import org .springframework .context .annotation .ComponentScan ;
6- import org .springframework .context .annotation .FilterType ;
75import org .springframework .stereotype .Component ;
86
97@ SpringBootApplication
10- @ ComponentScan (excludeFilters = {@ ComponentScan .Filter (type = FilterType .REGEX , pattern = "checks.spring.s4605.springBootApplication.app.smth" )})
118public class SpringBootApp1 {
129
1310 public static void main (String [] args ) {
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -115,7 +115,6 @@ void testSpringBootApplication() {
115115 List <String > files = Arrays .asList (
116116 mainCodeSourcesPath (testFolder + "Ko/Ko.java" ),
117117 mainCodeSourcesPath (testFolder + "app/Ok/Ok.java" ),
118- mainCodeSourcesPath (testFolder + "app/notOk/NotOkImpl.java" ),
119118 mainCodeSourcesPath (testFolder + "app/SpringBootApp1.java" ),
120119 mainCodeSourcesPath (testFolder + "secondApp/AnotherOk.java" ),
121120 mainCodeSourcesPath (testFolder + "secondApp/SpringBootApp2.java" ));
@@ -158,6 +157,19 @@ void testSpringBootApplicationWithAnnotation() {
158157 .verifyIssues ();
159158 }
160159
160+ @ Test
161+ void testBothAnnotationsTogether () {
162+ final String folderApp = BASE_PATH + "mixed/app1/" ;
163+ List <String > testFiles = Arrays .asList (
164+ mainCodeSourcesPath (folderApp + "App1.java" ),
165+ mainCodeSourcesPath (folderApp + "visible/VisibleService.java" ));
166+
167+ CheckVerifier .newVerifier ()
168+ .onFiles (testFiles )
169+ .withCheck (new SpringBeansShouldBeAccessibleCheck ())
170+ .verifyNoIssues ();
171+ }
172+
161173 @ Test
162174 void caching () throws NoSuchAlgorithmException , IOException {
163175 var unchangedFiles = Stream .of (
You can’t perform that action at this time.
0 commit comments