Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for @Wither in couchbase container (issues: #784) #810

Merged
merged 1 commit into from
Jul 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import lombok.Cleanup;
import lombok.Getter;
import lombok.SneakyThrows;
import lombok.experimental.Wither;
import org.apache.commons.compress.utils.Sets;
import org.jetbrains.annotations.NotNull;
import org.testcontainers.containers.GenericContainer;
Expand All @@ -53,46 +52,35 @@
public class CouchbaseContainer extends GenericContainer<CouchbaseContainer> {

public static final String VERSION = "5.1.0";
public static final String DOCKER_IMAGE_NAME = "couchbase/server:";
public static final ObjectMapper MAPPER = new ObjectMapper();

@Wither
private String memoryQuota = "300";

@Wither
private String indexMemoryQuota = "300";

@Wither
private String clusterUsername = "Administrator";

@Wither
private String clusterPassword = "password";

@Wither
private boolean keyValue = true;

@Getter
@Wither
private boolean query = true;

@Getter
@Wither
private boolean index = true;

@Getter
@Wither
private boolean primaryIndex = true;

@Getter
@Wither
private boolean fts = false;

@Wither
private boolean beerSample = false;

@Wither
private boolean travelSample = false;

@Wither
private boolean gamesIMSample = false;

@Getter(lazy = true)
Expand All @@ -106,7 +94,7 @@ public class CouchbaseContainer extends GenericContainer<CouchbaseContainer> {
private String urlBase;

public CouchbaseContainer() {
super("couchbase/server:" + VERSION);
super(DOCKER_IMAGE_NAME + VERSION);
}

public CouchbaseContainer(String containerName) {
Expand Down Expand Up @@ -273,4 +261,59 @@ private DefaultCouchbaseEnvironment createCouchbaseEnvironment() {
.bootstrapHttpSslPort(getMappedPort(18091))
.build();
}

public CouchbaseContainer withMemoryQuota(String memoryQuota) {
this.memoryQuota = memoryQuota;
return self();
}

public CouchbaseContainer withIndexMemoryQuota(String indexMemoryQuota) {
this.indexMemoryQuota = indexMemoryQuota;
return self();
}

public CouchbaseContainer withClusterPassword(String clusterPassword) {
this.clusterPassword = clusterPassword;
return self();
}

public CouchbaseContainer withKeyValue(boolean keyValue) {
this.keyValue = keyValue;
return self();
}

public CouchbaseContainer withQuery(boolean query) {
this.query = query;
return self();
}

public CouchbaseContainer withIndex(boolean index) {
this.index = index;
return self();
}

public CouchbaseContainer withPrimaryIndex(boolean primaryIndex) {
this.primaryIndex = primaryIndex;
return self();
}

public CouchbaseContainer withFts(boolean fts) {
this.fts = fts;
return self();
}

public CouchbaseContainer withBeerSample(boolean beerSample) {
this.beerSample = beerSample;
return self();
}

public CouchbaseContainer withTravelSample(boolean travelSample) {
this.travelSample = travelSample;
return self();
}

public CouchbaseContainer withGamesIMSample(boolean gamesIMSample) {
this.gamesIMSample = gamesIMSample;
return self();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,12 @@ public void shouldExecuteN1ql() {
Assert.assertEquals(1, n1qlQueryRows.size());
Assert.assertEquals(DOCUMENT, n1qlQueryRows.get(0).value().get(TEST_BUCKET).toString());
}

@Test
public void shouldUseCorrectDockerImage() {
CouchbaseContainer couchbaseContainer = new CouchbaseContainer().withBeerSample(true);

Assert.assertEquals(CouchbaseContainer.DOCKER_IMAGE_NAME + CouchbaseContainer.VERSION,
couchbaseContainer.getDockerImageName());
}
}