Skip to content

Commit 74f0e64

Browse files
committed
Block operations such as LogMessageWaitStrategy in hollow mode
1 parent 0cc7e0e commit 74f0e64

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,12 @@
5454
import org.microshed.testing.testcontainers.internal.ImageFromDockerfile;
5555
import org.microshed.testing.testcontainers.spi.ServerAdapter;
5656
import org.testcontainers.DockerClientFactory;
57+
import org.testcontainers.containers.BindMode;
5758
import org.testcontainers.containers.GenericContainer;
59+
import org.testcontainers.containers.SelinuxContext;
5860
import org.testcontainers.containers.output.Slf4jLogConsumer;
5961
import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;
62+
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
6063
import org.testcontainers.containers.wait.strategy.Wait;
6164
import org.testcontainers.containers.wait.strategy.WaitStrategy;
6265
import org.testcontainers.utility.Base58;
@@ -435,15 +438,23 @@ public ApplicationContainer withReadinessPath(String readinessUrl,
435438
@Override
436439
public ApplicationContainer waitingFor(WaitStrategy waitStrategy) {
437440
waitStrategySet = true;
441+
checkHollowWaitStrategy(waitStrategy);
438442
return super.waitingFor(waitStrategy);
439443
}
440444

441445
@Override
442446
public void setWaitStrategy(WaitStrategy waitStrategy) {
443447
waitStrategySet = true;
448+
checkHollowWaitStrategy(waitStrategy);
444449
super.setWaitStrategy(waitStrategy);
445450
}
446451

452+
private void checkHollowWaitStrategy(WaitStrategy strat) {
453+
if (isHollow && waitStrategy instanceof LogMessageWaitStrategy) {
454+
throw new UnsupportedOperationException("WaitStrategy [" + strat + "] is not supported in hollow container mode");
455+
}
456+
}
457+
447458
/**
448459
* Configures the application container with the supplied MicroProfile REST Client class that
449460
* will reference the supplied {@code hostUrl}
@@ -537,6 +548,35 @@ public ApplicationContainer withReuse(boolean reusable) {
537548
return this;
538549
}
539550

551+
@Override
552+
public ApplicationContainer withFileSystemBind(String hostPath, String containerPath) {
553+
requireNonHollow();
554+
return super.withFileSystemBind(hostPath, containerPath);
555+
}
556+
557+
@Override
558+
public ApplicationContainer withFileSystemBind(String hostPath, String containerPath, BindMode mode) {
559+
requireNonHollow();
560+
return super.withFileSystemBind(hostPath, containerPath, mode);
561+
}
562+
563+
@Override
564+
public void addFileSystemBind(String hostPath, String containerPath, BindMode mode) {
565+
requireNonHollow();
566+
super.addFileSystemBind(hostPath, containerPath, mode);
567+
}
568+
569+
@Override
570+
public void addFileSystemBind(String hostPath, String containerPath, BindMode mode, SelinuxContext selinuxContext) {
571+
requireNonHollow();
572+
super.addFileSystemBind(hostPath, containerPath, mode, selinuxContext);
573+
}
574+
575+
private void requireNonHollow() {
576+
if (isHollow)
577+
throw new UnsupportedOperationException("Operation not supported in hollow container mode");
578+
}
579+
540580
/**
541581
* @return The URL where the application is currently running at. The application URL is comprised
542582
* of the baseURL (as defined by {@link #getBaseURL()}) concatenated with the appContextRoot (as defined

0 commit comments

Comments
 (0)