Skip to content

Commit

Permalink
GH-1463: additional test cases for concatenated bean names in compone…
Browse files Browse the repository at this point in the history
…nt annotations
  • Loading branch information
martinlippert committed Feb 6, 2025
1 parent edbf870 commit 0851877
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ void testScanComponentClassWithName() throws Exception {
);
}

@Test
void testScanComponentClassWithNameAndStringConcatenation() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/SpecialNameComponentWithStringConcatenation.java").toUri().toString();
SpringIndexerHarness.assertDocumentSymbols(indexer, docUri,
SpringIndexerHarness.symbol("@Component(\"special\" + \"Name\")", "@+ 'specialName' (@Component) SpecialNameComponentWithStringConcatenation")
);
}

@Test
void testScanComponentClassWithNameAndAttributeName() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/SpecialNameComponentWithAttributeName.java").toUri().toString();
Expand All @@ -161,6 +169,22 @@ void testScanComponentClassWithNameAndAttributeName() throws Exception {
);
}

@Test
void testScanComponentClassWithNameAndAttributeNameWithStringConcatenation() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/SpecialNameComponentWithAttributeNameWithStringConcatenation.java").toUri().toString();
SpringIndexerHarness.assertDocumentSymbols(indexer, docUri,
SpringIndexerHarness.symbol("@Component(value = \"specialName\" + \"WithAttributeName\")", "@+ 'specialNameWithAttributeName' (@Component) SpecialNameComponentWithAttributeNameWithStringConcatenation")
);
}

@Test
void testScanComponentClassWithNameWithStringConcatenationAndConstant() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/SpecialNameComponentWithStringConcatenationAndConstant.java").toUri().toString();
SpringIndexerHarness.assertDocumentSymbols(indexer, docUri,
SpringIndexerHarness.symbol("@Component(\"special\" + \"Name\" + Constants.SAMPLE_CONSTANT)", "@+ 'specialNameSampleConstant' (@Component) SpecialNameComponentWithStringConcatenationAndConstant")
);
}

@Test
void testScanSimpleControllerClass() throws Exception {
String docUri = directory.toPath().resolve("src/main/java/org/test/SimpleController.java").toUri().toString();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.test;

public class Constants {

public static final String SAMPLE_CONSTANT = "SampleConstant";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.test;

import org.springframework.stereotype.Component;

@Component(value = "specialName" + "WithAttributeName")
public class SpecialNameComponentWithAttributeNameWithStringConcatenation {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.test;

import org.springframework.stereotype.Component;

@Component("special" + "Name")
public class SpecialNameComponentWithStringConcatenation {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.test;

import org.springframework.stereotype.Component;

@Component("special" + "Name" + Constants.SAMPLE_CONSTANT)
public class SpecialNameComponentWithStringConcatenationAndConstant {
}

0 comments on commit 0851877

Please sign in to comment.