|
|
|
@ -44,6 +44,7 @@ import org.eclipse.leshan.core.request.UpdateRequest; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.mockito.Mockito; |
|
|
|
import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClient; |
|
|
|
import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClientContext; |
|
|
|
import org.thingsboard.server.transport.lwm2m.server.uplink.DefaultLwM2mUplinkMsgHandler; |
|
|
|
import org.thingsboard.server.transport.lwm2m.utils.LwM2mValueConverterImpl; |
|
|
|
|
|
|
|
@ -113,11 +114,15 @@ public class LwM2MTestClient { |
|
|
|
private LwM2MClientState clientState; |
|
|
|
private Set<LwM2MClientState> clientStates; |
|
|
|
private DefaultLwM2mUplinkMsgHandler defaultLwM2mUplinkMsgHandlerTest; |
|
|
|
private LwM2mClientContext clientContext; |
|
|
|
|
|
|
|
public void init(Security security, Configuration coapConfig, int port, boolean isRpc, boolean isBootstrap, |
|
|
|
int shortServerId, int shortServerIdBs, Security securityBs, DefaultLwM2mUplinkMsgHandler defaultLwM2mUplinkMsgHandler) throws InvalidDDFFileException, IOException { |
|
|
|
int shortServerId, int shortServerIdBs, Security securityBs, |
|
|
|
DefaultLwM2mUplinkMsgHandler defaultLwM2mUplinkMsgHandler, |
|
|
|
LwM2mClientContext clientContext) throws InvalidDDFFileException, IOException { |
|
|
|
Assert.assertNull("client already initialized", leshanClient); |
|
|
|
this.defaultLwM2mUplinkMsgHandlerTest = defaultLwM2mUplinkMsgHandler; |
|
|
|
this.clientContext = clientContext; |
|
|
|
List<ObjectModel> models = new ArrayList<>(); |
|
|
|
for (String resourceName : resources) { |
|
|
|
models.addAll(ObjectLoader.loadDdfFile(LwM2MTestClient.class.getClassLoader().getResourceAsStream("lwm2m/" + resourceName), resourceName)); |
|
|
|
@ -334,10 +339,9 @@ public class LwM2MTestClient { |
|
|
|
} |
|
|
|
|
|
|
|
private void awaitClientAfterStartConnectLw() { |
|
|
|
LwM2mClient lwM2MClient = this.defaultLwM2mUplinkMsgHandlerTest.clientContext.getClientByEndpoint(endpoint); |
|
|
|
LwM2mClient lwM2MClient = this.clientContext.getClientByEndpoint(endpoint); |
|
|
|
CountDownLatch latch = new CountDownLatch(1); |
|
|
|
Mockito.doAnswer(invocation -> { |
|
|
|
// Object result = invocation.callRealMethod();
|
|
|
|
latch.countDown(); |
|
|
|
return null; |
|
|
|
}).when(defaultLwM2mUplinkMsgHandlerTest).initAttributes(lwM2MClient, true); |
|
|
|
|