Skip to content
This repository was archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
update README
Browse files Browse the repository at this point in the history
  • Loading branch information
whummer committed Feb 24, 2020
1 parent d3f697c commit d62aab7
Showing 1 changed file with 2 additions and 40 deletions.
42 changes: 2 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,7 @@ awslocal lambda create-function --function-name myLambda \

## Integration with Java/JUnit

In order to use LocalStack with Java, the project ships with a simple JUnit runner and a JUnit 5
extension. Take a look at the example JUnit tests in `ext/java`.

By default, the JUnit Test Runner starts LocalStack in a Docker container, for the duration of the test.
The container can be configured by using the `@LocalstackDockerProperties` annotation.
In order to use LocalStack with Java, the project ships with a simple JUnit runner, see sample below.

```
...
Expand All @@ -394,44 +390,10 @@ public class MyCloudAppTest {
List<Bucket> buckets = s3.listBuckets();
...
}
}
```

Or with JUnit 5 :

```
@ExtendWith(LocalstackDockerExtension.class)
@LocalstackDockerProperties(...)
public class MyCloudAppTest {
...
}
```

The LocalStack JUnit test runner is published as an artifact in Maven Central.
Simply add the following dependency to your `pom.xml` file:

```
<dependency>
<groupId>cloud.localstack</groupId>
<artifactId>localstack-utils</artifactId>
<version>0.2.0</version>
</dependency>
```

You can configure the Docker behaviour using the `@LocalstackDockerProperties` annotation with the following parameters:

| property | usage | type | default value |
|-----------------------------|------------------------------------------------------------------------------------------------------------------------------|------------------------------|---------------|
| `pullNewImage` | Determines if a new image is pulled from the docker repo before the tests are run. | boolean | `false` |
| `randomizePorts` | Determines if the container should expose the default local stack ports (4567-4583) or if it should expose randomized ports. | boolean | `false` |
| `services` | Determines which services should be run when the localstack starts. | String[] | All |
| `imageTag` | Use a specific image tag for docker container | String | `latest` |
| `hostNameResolver` | Used for determining the host name of the machine running the docker containers so that the containers can be addressed. | IHostNameResolver | `localhost` |
| `environmentVariableProvider` | Used for injecting environment variables into the container. | IEnvironmentVariableProvider | Empty Map |
| `useSingleDockerContainer` | Whether a singleton container should be used by all test classes. | boolean | `false` |

_Note: When specifying the port in the `services` property, you cannot use `randomizePorts = true`_
For more details and a complete list of configuration parameters, please refer to the [LocalStack Java Utils](https://github.com/localstack/localstack-java-utils) repository.

### Troubleshooting

Expand Down

0 comments on commit d62aab7

Please sign in to comment.