Java Control Client
A typed Java client for the emulator’s control REST API. Test code uses it to drive one emulator process: start and stop devices, send events, read and write parameters, read logs and change the process-wide properties. It wraps the endpoints described in REST API.
Overview
| Item | Value |
|---|---|
Maven coordinates |
|
Java |
25 |
Compile dependencies |
|
Entry point |
|
Packages |
|
Publication |
Releases are published to GitHub Packages of the TR069_Emulator repository by a tag-driven release workflow. No release has been published yet; build from the |
One Tr069EmulatorClient object serves one emulator process. It holds one HTTP client and no other state, and it is safe to share between threads. The control API it calls has no authentication, so point it at an emulator on an internal network only.
Operations
Two static factories and 21 instance methods. Endpoint groups are described in Load Test API (/api) and Single Mode API (/apiV2).
| Method | HTTP operation | Returns |
|---|---|---|
|
none; exchange timeout 30 s, connect timeout 5 s |
the client |
|
none; the timeout bounds one whole exchange, body included |
the client |
|
|
|
|
|
|
|
|
|
|
|
nothing |
|
|
|
|
|
nothing |
|
|
nothing |
|
|
|
|
|
nothing |
|
|
nothing |
|
|
|
|
|
|
|
|
nothing |
|
|
|
|
|
|
|
|
|
|
|
nothing |
|
|
|
|
|
nothing |
|
position 0: |
|
|
|
|
Model and Error Types
The model package holds plain records and enums, with member names equal to the JSON member names of the API (see Data Models).
| Type | Content |
|---|---|
|
|
|
|
|
|
|
the members of |
|
|
|
the 19 general members of |
|
built with |
|
|
|
|
|
|
Errors:
-
Tr069EmulatorExceptionis unchecked. Itskind()is anErrorKindEnum:UNREACHABLE(timeout or I/O failure),UNEXPECTED_STATUS(an HTTP status the operation does not expect),CONTRACT(the response does not have the declared shape) orBUSY(invokeWhenIdleran out of budget). It also offersoperation(),serial()andhttpStatus(). -
An argument rejected before any request is an
IllegalArgumentException, not this exception: nothing was exchanged. -
A message carries the kind, the operation, the serial and the HTTP status, never a request body, a response body or a parameter value.
See Error Handling for the HTTP statuses of the API itself.
Rules for Test Authors
| Topic | Rule |
|---|---|
Response shape |
A response that is not valid JSON, lacks a declared member, or holds a member of the wrong type is a |
|
|
|
After a 409 it polls |
|
Needs the emulator to run with |
|
404 gives an empty |
URL and JSON encoding |
The client URL-encodes serials and parameter names in query strings and JSON-escapes them in bodies. Pass them raw. |
Timeouts |
A timeout or I/O failure is |
|
It reads the current properties first and sends the current |
|
|
|
It stops and unschedules every device of the process, single devices included. Afterwards a single device still reads its own values, but |
|
It returns before the stop is complete (the emulator stops asynchronously, within 3 s). Before you reuse the serial, wait until |
|
The new interval is used from the end of the next session. The timer armed at the previous session end still fires, so a device left alone sends |
|
True means the value changed, the parameter’s notification is 2, and the emulator handed a |
|
It always sends |
Argument checks |
The client rejects, before any request, a base URI that is not an absolute |
Properties Are Process-Global and Order-Sensitive
The properties belong to the emulator process, not to a device. Every device and every caller shares them. A member that is read when a device is created, for example periodicInformEnabled, must be set before the device starts: call updateProperties before startDevice. Changing it afterwards does not change a device that already exists.
Usage Example
Tr069EmulatorClient emulator = Tr069EmulatorClient.create(URI.create("http://127.0.0.1:8080"));
emulator.updateProperties(PropertiesPatch.builder().periodicInformEnabled(true).build());
String serial = "TEST-0001";
emulator.startDevice(new DeviceSpec(serial, "https://acs.example.invalid/cwmp", "example-tree.xml", null, null));
emulator.invokeWhenIdle(serial, CpeEventEnum.PERIODIC, Duration.ofSeconds(30));
Optional<ParameterValue> reading = emulator.parameterValue(serial, "Device.DeviceInfo.SerialNumber");
emulator.stopDevice(serial);
The parameter name depends on the root of the tree the device was started from. example-tree.xml stands for a file listed by parameterTrees().