Skip to content

Commit

Permalink
feat: add default constructor
Browse files Browse the repository at this point in the history
chore: update readme
  • Loading branch information
jarlah committed Oct 6, 2023
1 parent 8272b56 commit fb4c4ee
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ You can use the `@Container` annotation to start a Ceph container.

```java
@Container
CephContainer container = new CephContainer("quay.io/ceph/demo");
CephContainer container = new CephContainer();
```

### Custom image
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/org/testcontainers/containers/CephContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

/**
* Testcontainers implementation for Ceph.
* <p>
* <br />
* Supported image: {@code quay.io/ceph/demo}
* <p>
* <br />
* Defaults to {@code quay.io/ceph/demo:latest-quincy} aka v17 of Ceph
* <br />
* Exposed ports:
* <ul>
* <li>Ceph: 8080</li>
Expand All @@ -21,6 +23,8 @@
public class CephContainer extends GenericContainer<CephContainer> {
private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("quay.io/ceph/demo");

private static final String DEFAULT_IMAGE_TAG = "latest-quincy";

private static final String CEPH_RGW_DEFAULT_ACCESS_KEY = "accessKey";

private static final String CEPH_RGW_DEFAULT_SECRET_KEY = "secretKey";
Expand All @@ -37,6 +41,10 @@ public class CephContainer extends GenericContainer<CephContainer> {

private String cephSecretKey;

public CephContainer() {
this(DEFAULT_IMAGE_NAME.withTag(DEFAULT_IMAGE_TAG));
}

public CephContainer(final String dockerImageName) {
this(DockerImageName.parse(dockerImageName));
}
Expand Down
16 changes: 5 additions & 11 deletions src/test/java/org/testcontainers/containers/CephContainerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ public class CephContainerTest {
public void testBasicUsage() throws Exception {
try (
// minioContainer {
CephContainer container = new CephContainer("quay.io/ceph/demo:latest-quincy");
CephContainer container = new CephContainer();
// }
) {
container.start();

assertThat(container.getCephAccessKey()).isNotBlank();
assertThat(container.getCephSecretKey()).isNotBlank();

// configuringClient {
AWSCredentials credentials = new BasicAWSCredentials(
container.getCephAccessKey(),
Expand Down Expand Up @@ -56,16 +59,7 @@ public void testBasicUsage() throws Exception {
}

@Test
public void testDefaultUserPassword() {
try (CephContainer container = new CephContainer("quay.io/ceph/demo:latest")) {
container.start();
assertThat(container.getCephAccessKey()).isNotBlank();
assertThat(container.getCephSecretKey()).isNotBlank();
}
}

@Test
public void testOverwriteUserPassword() {
public void testOverrides() {
try (
// cephOverrides {
CephContainer container = new CephContainer("quay.io/ceph/demo:latest")
Expand Down

0 comments on commit fb4c4ee

Please sign in to comment.