Skip to content

Commit 2a49ffa

Browse files
author
Reinier Lamers
committed
update Dockerfile and README for split into separate dependencies
1 parent 727beb0 commit 2a49ffa

File tree

2 files changed

+46
-21
lines changed

2 files changed

+46
-21
lines changed

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ FROM openjdk:8
22

33
MAINTAINER NewMotion, [email protected]
44

5-
ADD target /app
5+
RUN mkdir app
6+
7+
ADD cmd/target/scala-2.12/docile.jar /app
68
ADD examples /app/examples
79

810
WORKDIR /app
@@ -11,5 +13,5 @@ ENV CHARGEPOINT_SERIAL=56565656
1113
ENV BACKOFFICE_URL=wss://example.com/ocppws/
1214
ENV SCRIPT=examples/ocpp1x/continuous-remote-listening.scala
1315

14-
CMD ["sh", "-c", "java -jar scala-2.12/docile.jar -c $CHARGEPOINT_SERIAL --forever $BACKOFFICE_URL $SCRIPT"]
16+
CMD ["sh", "-c", "java -jar docile.jar -c $CHARGEPOINT_SERIAL --forever $BACKOFFICE_URL $SCRIPT"]
1517

README.md

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,25 @@ There are by now four ways to run the simulator:
5252

5353
The simplest way to run docile-charge-point is on the command line so we will discuss that first.
5454

55-
You can run the simulator like this, from the root directory of the project:
55+
To run the simulator, you first have to compile it with this command:
5656

57+
```bash
58+
sbt assembly
5759
```
58-
sbt 'run -c <charge point ID> -v <OCPP version> <Central System endpoint URL> <test scripts...>'
60+
61+
When that completes successfully, you can run the simulator like this, from the root directory of the project:
62+
63+
```bash
64+
java -jar cmd/target/scala-2.12/docile.jar -c <charge point ID> -v <OCPP version> <Central System endpoint URL> <test scripts...>
5965
```
6066

6167
so e.g.:
6268

63-
```
64-
sbt 'run -c chargepoint0123 -v 1.6 ws://example.org/ocpp-j-endpoint examples/ocpp1x/heartbeat.scala'
69+
```bash
70+
java -jar cmd/target/scala-2.12/docile.jar -c chargepoint0123 -v 1.6 ws://example.org/ocpp-j-endpoint examples/ocpp1x/heartbeat.scala
6571
```
6672

67-
See `sbt 'run --help'` for more options.
73+
See `java -jar cmd/target/scala-2.12/docile.jar --help` for more options.
6874

6975
If you're looking for a Central System to run docile-charge-point against, check [SteVe](https://github.com/RWTH-i5-IDSG/steve) or [OCPP 1.6 Backend](https://github.com/gertjana/ocpp16-backend).
7076

@@ -198,15 +204,15 @@ transaction, I will see that one script failed and the other one passed. In the
198204
console, that looks like this:
199205

200206
```
201-
sbt 'run -c '03000001' ws://test-chargenetwork.thenewmotion.com/ocppws examples/heartbeat.scala examples/do-a-transaction.scala'
207+
java -jar cmd/target/scala-2.12/docile.jar -c '03000001' ws://example.com/ocpp examples/heartbeat.scala examples/do-a-transaction.scala
202208
Loading settings from plugins.sbt ...
203209
Loading project definition from /Users/reinier/Documents/Programs/docile-charge-point/project
204210
Loading settings from build.sbt ...
205211
Set current project to docile-charge-point (in build file:/Users/reinier/Documents/Programs/docile-charge-point/)
206212
Credentials file /Users/reinier/.ivy2/.credentials does not exist
207213
Packaging /Users/reinier/Documents/Programs/docile-charge-point/target/scala-2.11/docile-charge-point_2.11-0.1-SNAPSHOT.jar ...
208214
Done packaging.
209-
Running (fork) chargepoint.docile.Main -c 03000001 ws://test-chargenetwork.thenewmotion.com/ocppws examples/heartbeat.scala examples/do-a-transaction.scala
215+
Running (fork) chargepoint.docile.Main -c 03000001 ws://example.com/ocpp examples/heartbeat.scala examples/do-a-transaction.scala
210216
Going to run heartbeat
211217
>> HeartbeatReq
212218
<< HeartbeatRes(2018-04-02T20:38:13.342Z[UTC])
@@ -320,18 +326,10 @@ expectIncoming(
320326

321327
## Running on the command line with an interactive prompt
322328

323-
You can also go into an interactive testing session on the command line.
324-
325-
To get an interactive terminal, it's easiest to first compile using sbt:
329+
You can also go into an interactive testing session on the command line. To do that, pass the `-i` command line flag:
326330

327331
```
328-
sbt assembly
329-
```
330-
331-
And then run `docile-charge-point` directly using the `java` command:
332-
333-
```
334-
java -jar target/scala-2.11/docile.jar -i -v 1.6 -c chargepoint0123 ws://example.com/ocpp
332+
java -jar cmd/target/scala-2.12/docile.jar -i -v 1.6 -c chargepoint0123 ws://example.com/ocpp
335333
```
336334

337335
The `-i` option here tells `docile-charge-point` to go into interactive mode.
@@ -408,6 +406,8 @@ There is now a Dockerfile included, so you can run it in Docker if you want. Als
408406
To run it in Docker, do:
409407

410408
```
409+
$ sbt assembly
410+
411411
$ docker build -t docile-charge-point:latest .
412412
413413
$ docker run --rm -it docile-charge-point:latest
@@ -427,7 +427,7 @@ For maximum flexibility, you can embed docile-charge-point as a library dependen
427427
To make docile-charge-point a dependency of your Scala project, add this to your library dependencies in your `build.sbt`:
428428

429429
```scala
430-
"com.newmotion" %% "docile-charge-point" % "0.4.1"
430+
"com.newmotion" %% "docile-charge-point" % "0.5.0"
431431
```
432432

433433
and make sure that the NewMotion Nexus repository is in your sources by adding this to your `project/plugins.sbt`:
@@ -436,7 +436,30 @@ and make sure that the NewMotion Nexus repository is in your sources by adding t
436436
resolvers += "TNM" at "http://nexus.thenewmotion.com/content/groups/public"
437437
```
438438

439-
Then you can create test cases as instances of `chargepoint.docile.dsl.OcppTest` in your code and create instances of `chargepoint.docile.test.Runner` to execute them.
439+
Then, in your code:
440+
1. Create tests as instances of `chargepoint.docile.dsl.OcppTest` in your code
441+
1. Combine them with a testcase name to be a [`chargepoint.docile.test.TestCase`](core/src/main/scala/chargepoint/docile/test/TestCase.scala)
442+
1. Instantiate a [`chargepoint.docile.test.Runner`](core/src/main/scala/chargepoint/docile/test/Runner.scala) wrapping the test cases
443+
1. Call the `.run()` method on the `Runner`, passing a [`chargepoint.docile.test.RunnerConfig`](core/src/main/scala/chargepoint/docile/test/Runner.scala) to specify how you'd like the test to be executed
444+
445+
### Loading test cases distributed separately as files
446+
447+
To load text files as test cases, you need another library as a dependency:
448+
449+
```scala
450+
"com.newmotion" %% "docile-charge-point-loader" % "0.5.0"
451+
```
452+
453+
and of course also in this case the resolver in your `project/plugins.sbt`:
454+
455+
```scala
456+
resolvers += "TNM" at "http://nexus.thenewmotion.com/content/groups/public"
457+
```
458+
459+
Then you'll, besides all the classes for defining and running test cases
460+
mentioned above, also have a [`chargepoint.docile.test.Loader`](loader/src/main/scala/chargepoint/docile/test/Loader.scala)
461+
that has a few methods all called `runnerFor` that will give you a `Runner`
462+
instance based on a file, `String` or `Array[Byte]` for a test case.
440463

441464
One example where this is done is the AWS Lambda and S3 integration in the [lambda](aws-lambda/) subproject in this repository. Run `sbt lambda/run` to compile and run that code.
442465

0 commit comments

Comments
 (0)