GH-1463: additional test cases for concatenated bean names in component annotations

This commit is contained in:
Martin Lippert
2025-02-06 13:26:19 +01:00
parent edbf8706a5
commit 08518771a8
5 changed files with 52 additions and 0 deletions

View File

@@ -153,6 +153,14 @@ public class SpringIndexerBeansTest {
);
}
@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();
@@ -161,6 +169,22 @@ public class SpringIndexerBeansTest {
);
}
@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();

View File

@@ -0,0 +1,7 @@
package org.test;
public class Constants {
public static final String SAMPLE_CONSTANT = "SampleConstant";
}

View File

@@ -0,0 +1,7 @@
package org.test;
import org.springframework.stereotype.Component;
@Component(value = "specialName" + "WithAttributeName")
public class SpecialNameComponentWithAttributeNameWithStringConcatenation {
}

View File

@@ -0,0 +1,7 @@
package org.test;
import org.springframework.stereotype.Component;
@Component("special" + "Name")
public class SpecialNameComponentWithStringConcatenation {
}

View File

@@ -0,0 +1,7 @@
package org.test;
import org.springframework.stereotype.Component;
@Component("special" + "Name" + Constants.SAMPLE_CONSTANT)
public class SpecialNameComponentWithStringConcatenationAndConstant {
}