-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
GrpcCliTest.java
57 lines (49 loc) · 1.89 KB
/
GrpcCliTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package io.quarkus.grpc.cli;
import java.util.List;
import java.util.Optional;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import io.quarkus.test.junit.QuarkusTest;
@QuarkusTest
public class GrpcCliTest {
@Test
public void testCommand() {
StringBuffer buffer = new StringBuffer();
ListCommand listCommand = new ListCommand() {
@Override
protected void log(String msg) {
buffer.append(msg).append("\n");
}
};
listCommand.unmatched = List.of("localhost:8081");
Integer exitCode = listCommand.call();
Assertions.assertEquals(0, exitCode);
Assertions.assertTrue(buffer.toString().contains("helloworld.Greeter"));
buffer.setLength(0);
DescribeCommand describeCommand = new DescribeCommand() {
@Override
protected void log(String msg) {
buffer.append(msg).append("\n");
}
};
describeCommand.unmatched = List.of("localhost:8081", "helloworld.Greeter");
exitCode = describeCommand.call();
Assertions.assertEquals(0, exitCode);
String string = buffer.toString();
Assertions.assertTrue(string.contains("HelloRequest"));
Assertions.assertTrue(string.contains("HelloReply"));
buffer.setLength(0);
InvokeCommand invokeCommand = new InvokeCommand() {
@Override
protected void log(String msg) {
buffer.append(msg).append("\n");
}
};
invokeCommand.unmatched = List.of("localhost:8081", "helloworld.Greeter/SayHello");
invokeCommand.content = Optional.of("{\"name\" : \"Quarkus\"}");
exitCode = invokeCommand.call();
Assertions.assertEquals(0, exitCode);
string = buffer.toString();
Assertions.assertTrue(string.contains("Hello Quarkus"));
}
}