Skip to content

Commit ce75aad

Browse files
committed
test: add iotda server testcase
1 parent 39d1c6d commit ce75aad

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package io.github.protocol.mtconnect.server;
2+
3+
import io.github.openfacade.http.HttpServerConfig;
4+
import io.github.openfacade.http.HttpServerEngine;
5+
import io.github.protocol.mtconnect.api.Device;
6+
import io.github.protocol.mtconnect.api.MTConnectDevices;
7+
import io.github.protocol.mtconnect.server.impl.IoTDAMtProcessor;
8+
import io.github.protocol.mtconnect.server.impl.MemoryMtProcessor;
9+
import org.junit.jupiter.api.Assertions;
10+
import org.junit.jupiter.api.Test;
11+
12+
import java.util.concurrent.ExecutionException;
13+
14+
public class IoTDAServerTest {
15+
16+
private int port;
17+
private final String localHost = "127.0.0.1";
18+
19+
// start memory server
20+
private MTConnectServer startIoTDAServer() {
21+
MTConnectServerConfiguration configuration = new MTConnectServerConfiguration();
22+
HttpServerConfig httpServerConfig = new HttpServerConfig.Builder()
23+
.engine(HttpServerEngine.Vertx)
24+
.host("127.0.0.1")
25+
.port(36633)
26+
.build();
27+
configuration.setHttpConfig(httpServerConfig);
28+
IoTDAMtProcessor ioTDAMtProcessor = new IoTDAMtProcessor.Builder()
29+
.setAk("MOCK_CLOUD_SDK_AK")
30+
.setSk("MOCK_CLOUD_SDK_SK")
31+
.setEndpoint("MOCK_CLOUD_SDK_ENDPOINT")
32+
.build();
33+
34+
configuration.setMtProcessor(ioTDAMtProcessor);
35+
MTConnectServer mtConnectServer = new MTConnectServer(configuration);
36+
mtConnectServer.start().join();
37+
38+
return mtConnectServer;
39+
}
40+
41+
@Test
42+
public void testDevices() throws ExecutionException, InterruptedException {
43+
MTConnectServer mtConnectServer = startIoTDAServer();
44+
Assertions.assertTrue(mtConnectServer.httpPort() > 0);
45+
}
46+
}

0 commit comments

Comments
 (0)