Skip to content

Commit e9997d4

Browse files
committed
Polish
1 parent 354117d commit e9997d4

File tree

14 files changed

+28
-37
lines changed

14 files changed

+28
-37
lines changed

spring-core-test/src/main/java/org/springframework/aot/test/generate/compile/CompileWithTargetClassAccessClassLoader.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import java.net.URL;
2222
import java.util.Enumeration;
2323

24+
import org.springframework.lang.Nullable;
25+
2426
/**
2527
* {@link ClassLoader} implementation to support
2628
* {@link CompileWithTargetClassAccess @CompileWithTargetClassAccess}.
@@ -74,6 +76,7 @@ protected Enumeration<URL> findResources(String name) throws IOException {
7476
}
7577

7678
@Override
79+
@Nullable
7780
protected URL findResource(String name) {
7881
return this.testClassLoader.getResource(name);
7982
}

spring-core-test/src/main/java/org/springframework/aot/test/generate/compile/DynamicClassLoader.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ private static class ResourceFileHandler extends URLStreamHandler {
158158

159159

160160
@Override
161-
protected URLConnection openConnection(URL url) throws IOException {
161+
protected URLConnection openConnection(URL url) {
162162
return new ResourceFileConnection(url, this.file);
163163
}
164164

@@ -177,11 +177,11 @@ protected ResourceFileConnection(URL url, ResourceFile file) {
177177

178178

179179
@Override
180-
public void connect() throws IOException {
180+
public void connect() {
181181
}
182182

183183
@Override
184-
public InputStream getInputStream() throws IOException {
184+
public InputStream getInputStream() {
185185
return new ByteArrayInputStream(
186186
this.file.getContent().getBytes(StandardCharsets.UTF_8));
187187
}

spring-core-test/src/main/java/org/springframework/aot/test/generate/file/DynamicFile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public abstract sealed class DynamicFile permits SourceFile, ResourceFile {
3838

3939

4040
protected DynamicFile(String path, String content) {
41-
Assert.hasText(path, "Path must not be empty");
42-
Assert.hasText(content, "Content must not be empty");
41+
Assert.hasText(path, "'path' must not be empty");
42+
Assert.hasText(content, "'content' must not be empty");
4343
this.path = path;
4444
this.content = content;
4545
}

spring-core-test/src/main/java/org/springframework/aot/test/generate/file/DynamicFiles.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
final class DynamicFiles<F extends DynamicFile> implements Iterable<F> {
3939

4040

41-
private static final DynamicFiles<?> NONE = new DynamicFiles<>(
42-
Collections.emptyMap());
41+
private static final DynamicFiles<?> NONE = new DynamicFiles<>(Collections.emptyMap());
4342

4443

4544
private final Map<String, F> files;

spring-core-test/src/main/java/org/springframework/aot/test/generate/file/ResourceFile.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.assertj.core.api.AssertProvider;
2323

2424
import org.springframework.core.io.InputStreamSource;
25-
import org.springframework.lang.Nullable;
2625
import org.springframework.util.FileCopyUtils;
2726

2827
/**
@@ -32,8 +31,7 @@
3231
* @author Phillip Webb
3332
* @since 6.0
3433
*/
35-
public final class ResourceFile extends DynamicFile
36-
implements AssertProvider<ResourceFileAssert> {
34+
public final class ResourceFile extends DynamicFile implements AssertProvider<ResourceFileAssert> {
3735

3836

3937
private ResourceFile(String path, String content) {
@@ -46,7 +44,7 @@ private ResourceFile(String path, String content) {
4644
* {@link CharSequence}.
4745
* @param path the relative path of the file or {@code null} to have the
4846
* path deduced
49-
* @param charSequence a file containing the source contents
47+
* @param charSequence a file containing the file contents
5048
* @return a {@link ResourceFile} instance
5149
*/
5250
public static ResourceFile of(String path, CharSequence charSequence) {
@@ -56,24 +54,21 @@ public static ResourceFile of(String path, CharSequence charSequence) {
5654
/**
5755
* Factory method to create a new {@link ResourceFile} from the given
5856
* {@link InputStreamSource}.
59-
* @param path the relative path of the file or {@code null} to have the
60-
* path deduced
57+
* @param path the relative path of the file
6158
* @param inputStreamSource the source for the file
62-
* @return a {@link SourceFile} instance
59+
* @return a {@link ResourceFile} instance
6360
*/
64-
public static ResourceFile of(@Nullable String path,
65-
InputStreamSource inputStreamSource) {
61+
public static ResourceFile of(String path, InputStreamSource inputStreamSource) {
6662
return of(path, appendable -> appendable.append(FileCopyUtils.copyToString(
6763
new InputStreamReader(inputStreamSource.getInputStream(), StandardCharsets.UTF_8))));
6864
}
6965

7066
/**
7167
* Factory method to create a new {@link SourceFile} from the given
7268
* {@link WritableContent}.
73-
* @param path the relative path of the file or {@code null} to have the
74-
* path deduced
69+
* @param path the relative path of the file
7570
* @param writableContent the content to write to the file
76-
* @return a {@link SourceFile} instance
71+
* @return a {@link ResourceFile} instance
7772
*/
7873
public static ResourceFile of(String path, WritableContent writableContent) {
7974
return new ResourceFile(path, toString(writableContent));

spring-core-test/src/main/java/org/springframework/aot/test/generate/file/ResourceFiles.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public boolean isEmpty() {
111111

112112
/**
113113
* Get the {@link ResourceFile} with the given
114-
* {@code DynamicFile#getPath() path}.
114+
* {@linkplain DynamicFile#getPath() path}.
115115
* @param path the path to find
116116
* @return a {@link ResourceFile} instance or {@code null}
117117
*/
@@ -121,7 +121,7 @@ public ResourceFile get(String path) {
121121
}
122122

123123
/**
124-
* Return the single source file contained in the collection.
124+
* Return the single {@link ResourceFile} contained in the collection.
125125
* @return the single file
126126
* @throws IllegalStateException if the collection doesn't contain exactly
127127
* one file

spring-core-test/src/main/java/org/springframework/aot/test/generate/file/SourceFile.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,16 @@
3535

3636
/**
3737
* {@link DynamicFile} that holds Java source code and provides
38-
* {@link SourceFileAssert} support. Usually created from an AOT generated type,
39-
* for example:
40-
*
38+
* {@link SourceFileAssert} support. Usually created from an AOT generated
39+
* type, for example:
4140
* <pre class="code">
4241
* SourceFile.of(generatedFile::writeTo)
4342
* </pre>
4443
*
4544
* @author Phillip Webb
4645
* @since 6.0
4746
*/
48-
public final class SourceFile extends DynamicFile
49-
implements AssertProvider<SourceFileAssert> {
47+
public final class SourceFile extends DynamicFile implements AssertProvider<SourceFileAssert> {
5048

5149

5250
private final String className;

spring-core-test/src/main/java/org/springframework/aot/test/generate/file/SourceFiles.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public boolean isEmpty() {
114114

115115
/**
116116
* Get the {@link SourceFile} with the given
117-
* {@code DynamicFile#getPath() path}.
117+
* {@linkplain DynamicFile#getPath() path}.
118118
* @param path the path to find
119119
* @return a {@link SourceFile} instance or {@code null}
120120
*/

spring-core-test/src/main/java/org/springframework/aot/test/generate/file/package-info.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
/**
22
* Support classes for running assertions on generated files.
3-
*
4-
* @author Stephane Nicoll
53
*/
64
@NonNullApi
75
@NonNullFields

spring-core-test/src/test/java/org/springframework/aot/test/generate/compile/CompiledTests.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,13 @@ void getResourceFileWhenMultipleThrowsException() {
107107
ResourceFile.of("META-INF/myfile1", "test1"),
108108
ResourceFile.of("META-INF/myfile2", "test2"));
109109
TestCompiler.forSystem().withResources(resourceFiles).compile(
110-
compiled -> assertThatIllegalStateException().isThrownBy(
111-
() -> compiled.getResourceFile()));
110+
compiled -> assertThatIllegalStateException().isThrownBy(compiled::getResourceFile));
112111
}
113112

114113
@Test
115114
void getResourceFileWhenNoneThrowsException() {
116115
TestCompiler.forSystem().compile(
117-
compiled -> assertThatIllegalStateException().isThrownBy(
118-
() -> compiled.getResourceFile()));
116+
compiled -> assertThatIllegalStateException().isThrownBy(compiled::getResourceFile));
119117
}
120118

121119
@Test

0 commit comments

Comments
 (0)