Skip to content

Commit c87c85c

Browse files
committed
Block ApplicationContainer#withReuse(true)
1 parent b53e314 commit c87c85c

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

modules/testcontainers/src/main/java/org/microshed/testing/testcontainers/ApplicationContainer.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
import java.lang.annotation.Annotation;
2424
import java.lang.reflect.InvocationTargetException;
2525
import java.lang.reflect.Method;
26-
import java.net.MalformedURLException;
27-
import java.net.URL;
26+
import java.net.URI;
2827
import java.nio.file.Files;
2928
import java.nio.file.Path;
3029
import java.nio.file.Paths;
@@ -460,11 +459,7 @@ public ApplicationContainer withMpRestClient(Class<?> restClientClass, String ho
460459
if (!restClientClass.isInterface()) {
461460
throw new IllegalArgumentException("Provided restClientClass " + restClientClass.getCanonicalName() + " must be an interface");
462461
}
463-
try {
464-
new URL(hostUrl);
465-
} catch (MalformedURLException e) {
466-
throw new IllegalArgumentException(e);
467-
}
462+
URI.create(hostUrl);
468463
String configToken = readMpRestClientConfigKey(restClientClass);
469464
if (configToken == null || configToken.isEmpty())
470465
configToken = restClientClass.getCanonicalName();
@@ -524,14 +519,20 @@ public ApplicationContainer withMpRestClient(String restClientClass, String host
524519
} else {
525520
restClientClass += "/mp-rest/url";
526521
}
527-
try {
528-
new URL(hostUrl);
529-
} catch (MalformedURLException e) {
530-
throw new IllegalArgumentException(e);
531-
}
522+
URI.create(hostUrl);
532523
return withEnv(restClientClass, hostUrl);
533524
}
534525

526+
@Override
527+
public ApplicationContainer withReuse(boolean reusable) {
528+
if (reusable) {
529+
throw new UnsupportedOperationException("Container reuse is not supported for ApplicationContainer. " +
530+
"Instead, see HollowTestContainersConfiguration documentation: " +
531+
"https://microshed.org/microshed-testing/features/ApplicationEnvironment.html");
532+
}
533+
return super.withReuse(reusable);
534+
}
535+
535536
/**
536537
* @return The URL where the application is currently running at. The application URL is comprised
537538
* of the baseURL (as defined by {@link #getBaseURL()}) concatenated with the appContextRoot (as defined

0 commit comments

Comments
 (0)