Polishing

This commit is contained in:
Sam Brannen
2024-04-08 17:02:08 +02:00
parent ac74116d76
commit 187f641409
3 changed files with 12 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,9 @@ package a;
/**
* Test class for {@code org.springframework.util.ClassUtilsTests}.
*
* <p>The use case for this test class requires that the package name is a single
* character (i.e., length of 1).
*
* @author Johnny Lim
*/
public class ClassHavingNestedClass {

View File

@@ -33,6 +33,7 @@ import java.util.List;
import java.util.Set;
import java.util.function.Supplier;
import a.ClassHavingNestedClass;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
@@ -86,8 +87,11 @@ class ClassUtilsTests {
void forNameWithNestedType() throws ClassNotFoundException {
assertThat(ClassUtils.forName("org.springframework.util.ClassUtilsTests$NestedClass", classLoader)).isEqualTo(NestedClass.class);
assertThat(ClassUtils.forName("org.springframework.util.ClassUtilsTests.NestedClass", classLoader)).isEqualTo(NestedClass.class);
assertThat(ClassUtils.forName("a.ClassHavingNestedClass$NestedClass", classLoader)).isEqualTo(a.ClassHavingNestedClass.NestedClass.class);
assertThat(ClassUtils.forName("a.ClassHavingNestedClass.NestedClass", classLoader)).isEqualTo(a.ClassHavingNestedClass.NestedClass.class);
// Precondition: package name must have length == 1.
assertThat(ClassHavingNestedClass.class.getPackageName().length()).isEqualTo(1);
assertThat(ClassUtils.forName("a.ClassHavingNestedClass$NestedClass", classLoader)).isEqualTo(ClassHavingNestedClass.NestedClass.class);
assertThat(ClassUtils.forName("a.ClassHavingNestedClass.NestedClass", classLoader)).isEqualTo(ClassHavingNestedClass.NestedClass.class);
}
@Test
@@ -625,6 +629,7 @@ class ClassUtilsTests {
}
@Override
public void packageAccessiblePrint() {
}