Skip to content

Commit

Permalink
docs: embed code snippets for the artemis module (#1502)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Aug 14, 2023
1 parent e39e2a0 commit d444c86
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 21 deletions.
42 changes: 21 additions & 21 deletions docs/modules/artemis.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ At the same time, it's possible to set a wait strategy and a custom deadline wit

If you need to change the default admin credentials (i.e. `artemis:artemis`) use `WithCredentials`.

```go
container, err := artemis.RunContainer(ctx, artemis.WithCredentials("user", "password"))
```
<!--codeinclude-->
[With credentials](../../modules/artemis/artemis_test.go) inside_block:withCredentials
<!--/codeinclude-->

#### Anonymous Login

If you need to enable anonymous logins (which are disabled by default) use `WithAnonymousLogin`.

```go
container, err := artemis.RunContainer(ctx, artemis.WithAnonymousLogin())
```
<!--codeinclude-->
[With Anonymous Login](../../modules/artemis/artemis_test.go) inside_block:withAnonymousLogin
<!--/codeinclude-->

#### Custom Arguments

Expand All @@ -73,9 +73,9 @@ The default is `--http-host 0.0.0.0 --relax-jolokia`.
Setting this value will override the default.
See the documentation on `artemis create` for available options.

```go
container, err := artemis.RunContainer(ctx, artemis.WithExtraArgs("--http-host 0.0.0.0 --relax-jolokia --queues ArgsTestQueue"))
```
<!--codeinclude-->
[With Extra Arguments](../../modules/artemis/artemis_test.go) inside_block:withExtraArgs
<!--/codeinclude-->

#### Docker type modifiers

Expand All @@ -95,30 +95,30 @@ The Artemis container exposes the following methods:

User returns the administrator username.

```go
user := container.User()
```
<!--codeinclude-->
[Retrieving the Administrator User](../../modules/artemis/example_test.go) inside_block:containerUser
<!--/codeinclude-->

#### Password

Password returns the administrator password.

```go
password := container.Password()
```
<!--codeinclude-->
[Retrieving the Administrator Password](../../modules/artemis/example_test.go) inside_block:containerPassword
<!--/codeinclude-->

#### BrokerEndpoint

BrokerEndpoint returns the host:port for the combined protocols endpoint.

```go
host, err := container.BrokerEndpoint(ctx)
```
<!--codeinclude-->
[Get broker endpoint](../../modules/artemis/artemis_test.go) inside_block:brokerEndpoint
<!--/codeinclude-->

#### ConsoleURL

ConsoleURL returns the URL for the management console.

```go
url, err := container.ConsoleURL(ctx)
```
<!--codeinclude-->
[Get console URL](../../modules/artemis/artemis_test.go) inside_block:consoleURL
<!--/codeinclude-->
10 changes: 10 additions & 0 deletions modules/artemis/artemis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,27 @@ func TestArtemis(t *testing.T) {
{
name: "WithCredentials",
opts: []testcontainers.ContainerCustomizer{
// withCredentials {
artemis.WithCredentials("test", "test"),
// }
},
user: "test",
pass: "test",
},
{
name: "WithAnonymous",
opts: []testcontainers.ContainerCustomizer{
// withAnonymousLogin {
artemis.WithAnonymousLogin(),
// }
},
},
{
name: "WithExtraArgs",
opts: []testcontainers.ContainerCustomizer{
// withExtraArgs {
artemis.WithExtraArgs("--http-host 0.0.0.0 --relax-jolokia --queues ArgsTestQueue"),
// }
},
user: "artemis",
pass: "artemis",
Expand All @@ -61,7 +67,9 @@ func TestArtemis(t *testing.T) {
require.NoError(t, err)
t.Cleanup(func() { require.NoError(t, container.Terminate(ctx), "failed to terminate container") })

// consoleURL {
u, err := container.ConsoleURL(ctx)
// }
require.NoError(t, err)

res, err := http.Get(u)
Expand All @@ -77,7 +85,9 @@ func TestArtemis(t *testing.T) {
assert.Equal(t, test.pass, container.Password(), "unexpected password")
}

// brokerEndpoint {
host, err := container.BrokerEndpoint(ctx)
// }
require.NoError(t, err)

var opt []func(*stomp.Conn) error
Expand Down
4 changes: 4 additions & 0 deletions modules/artemis/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ func ExampleRunContainer() {
}

// Get credentials.
// containerUser {
user := container.User()
// }
// containerPassword {
pass := container.Password()
// }

// Connect to Artemis via STOMP.
conn, err := stomp.Dial("tcp", host, stomp.ConnOpt.Login(user, pass))
Expand Down

0 comments on commit d444c86

Please sign in to comment.