Skip to content

Commit

Permalink
code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Rzeszutek committed Oct 19, 2022
1 parent 5a5bee8 commit 5eccd69
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public final class JarServiceNameProvider implements ConditionalResourceProvider

@SuppressWarnings("unused") // SPI
public JarServiceNameProvider() {
this(ProcessArguments::getProcessArguments, System::getProperty, Files::exists);
this(ProcessArguments::getProcessArguments, System::getProperty, Files::isRegularFile);
}

// visible for tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class JarServiceNameProviderTest {
@Test
void createResource_empty() {
JarServiceNameProvider serviceNameProvider =
new JarServiceNameProvider(() -> new String[0], prop -> null, file -> false);
new JarServiceNameProvider(
() -> new String[0], prop -> null, JarServiceNameProviderTest::failPath);

Resource resource = serviceNameProvider.createResource(config);

Expand All @@ -44,7 +45,7 @@ void createResource_empty() {
void createResource_noJarFileInArgs() {
String[] args = new String[] {"-Dtest=42", "-Xmx666m", "-jar"};
JarServiceNameProvider serviceNameProvider =
new JarServiceNameProvider(() -> args, prop -> null, file -> false);
new JarServiceNameProvider(() -> args, prop -> null, JarServiceNameProviderTest::failPath);

Resource resource = serviceNameProvider.createResource(config);

Expand All @@ -56,7 +57,7 @@ void createResource_processHandleJar() {
String[] args =
new String[] {"-Dtest=42", "-Xmx666m", "-jar", "/path/to/app/my-service.jar", "abc", "def"};
JarServiceNameProvider serviceNameProvider =
new JarServiceNameProvider(() -> args, prop -> null, file -> false);
new JarServiceNameProvider(() -> args, prop -> null, JarServiceNameProviderTest::failPath);

Resource resource = serviceNameProvider.createResource(config);

Expand All @@ -69,7 +70,7 @@ void createResource_processHandleJar() {
void createResource_processHandleJarWithoutExtension() {
String[] args = new String[] {"-Dtest=42", "-Xmx666m", "-jar", "/path/to/app/my-service"};
JarServiceNameProvider serviceNameProvider =
new JarServiceNameProvider(() -> args, prop -> null, file -> false);
new JarServiceNameProvider(() -> args, prop -> null, JarServiceNameProviderTest::failPath);

Resource resource = serviceNameProvider.createResource(config);

Expand Down Expand Up @@ -108,4 +109,8 @@ public Stream<? extends Arguments> provideArguments(ExtensionContext context) {
"/path to app/with spaces/my-service 1 2 3", "/path to app/with spaces/my-service"));
}
}

private static boolean failPath(Path file) {
throw new AssertionError("Unexpected call to Files.isRegularFile()");
}
}

0 comments on commit 5eccd69

Please sign in to comment.