Browse Source

Provide invalid class name in exception message

See gh-31612
6.0.x^2
PiotrFLEURY 1 year ago committed by Stéphane Nicoll
parent
commit
5ac4c3bd76
  1. 2
      spring-core/src/main/java/org/springframework/aot/generate/GeneratedFiles.java
  2. 2
      spring-core/src/test/java/org/springframework/aot/generate/GeneratedFilesTests.java

2
spring-core/src/main/java/org/springframework/aot/generate/GeneratedFiles.java

@ -161,7 +161,7 @@ public interface GeneratedFiles {
private static String getClassNamePath(String className) { private static String getClassNamePath(String className) {
Assert.hasLength(className, "'className' must not be empty"); Assert.hasLength(className, "'className' must not be empty");
Assert.isTrue(isJavaIdentifier(className), "'className' must be a valid identifier"); Assert.isTrue(isJavaIdentifier(className), "'className' " + className + " must be a valid identifier");
return ClassUtils.convertClassNameToResourcePath(className) + ".java"; return ClassUtils.convertClassNameToResourcePath(className) + ".java";
} }

2
spring-core/src/test/java/org/springframework/aot/generate/GeneratedFilesTests.java

@ -78,7 +78,7 @@ class GeneratedFilesTests {
assertThatIllegalArgumentException() assertThatIllegalArgumentException()
.isThrownBy(() -> this.generatedFiles .isThrownBy(() -> this.generatedFiles
.addSourceFile("com/example/HelloWorld.java", "{}")) .addSourceFile("com/example/HelloWorld.java", "{}"))
.withMessage("'className' must be a valid identifier"); .withMessage("'className' com/example/HelloWorld.java must be a valid identifier");
} }
@Test @Test

Loading…
Cancel
Save