调整项目结构
This commit is contained in:
@@ -2,12 +2,31 @@ package com.njcn;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.common.reflect.TypeToken;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.graphbuilder.math.func.EFunction;
|
||||
import com.njcn.access.pojo.dto.mqtt.MqttClientDto;
|
||||
import io.lettuce.core.protocol.CompleteableCommand;
|
||||
import okhttp3.Credentials;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppTest
|
||||
public class AppTest
|
||||
{
|
||||
/**
|
||||
* Rigorous Test :-)
|
||||
@@ -17,4 +36,31 @@ public class AppTest
|
||||
{
|
||||
assertTrue( true );
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
String username = "ac760c62395cecec";
|
||||
String password = "k0vGfe5xOE2Bl4DCF73uahcknvcwoKOEDPnOkMvuSBB";
|
||||
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
|
||||
Request request = new Request.Builder()
|
||||
.url("http://192.168.1.18:18083/api/v5/clients/access-boot123456")
|
||||
.header("Content-Type", "application/json")
|
||||
.header("Authorization", Credentials.basic(username, password))
|
||||
.build();
|
||||
|
||||
Response response = client.newCall(request).execute();
|
||||
response.body();
|
||||
String res = Objects.requireNonNull(response.body()).string();
|
||||
|
||||
Gson gson = new Gson();
|
||||
MqttClientDto mqttClientDto = gson.fromJson(res, new TypeToken<MqttClientDto>(){}.getType());
|
||||
System.out.println("mqttClientDto==:" + mqttClientDto.isConnected());
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user