|
| 1 | +package features; |
| 2 | + |
| 3 | +import org.junit.jupiter.api.Test; |
| 4 | +import org.noear.nami.annotation.NamiClient; |
| 5 | +import org.noear.solon.core.handle.UploadedFile; |
| 6 | +import org.noear.solon.core.util.MimeType; |
| 7 | +import org.noear.solon.test.SolonTest; |
| 8 | +import webapp.App; |
| 9 | +import webapp.demo5_rpc.HelloService; |
| 10 | +import webapp.demo5_rpc.HelloService2; |
| 11 | + |
| 12 | +import java.io.ByteArrayInputStream; |
| 13 | +import java.io.IOException; |
| 14 | +import java.util.ArrayList; |
| 15 | +import java.util.List; |
| 16 | + |
| 17 | +/** |
| 18 | + * @author noear 2025/5/7 created |
| 19 | + */ |
| 20 | +@SolonTest(App.class) |
| 21 | +public class NamiAndHttpTest2 { |
| 22 | + //直接指定服务端地址 |
| 23 | + @NamiClient(url = "http://localhost:8080/demo5/hello/") |
| 24 | + HelloService2 helloService; |
| 25 | + |
| 26 | + @Test |
| 27 | + public void hello() { |
| 28 | + assert helloService.hello("world", "1", "a").contains("world:1:a"); |
| 29 | + assert helloService.hello("solon", "2", "b").contains("solon:2:b"); |
| 30 | + } |
| 31 | + |
| 32 | + @Test |
| 33 | + public void test01() { |
| 34 | + List<String> ids = new ArrayList<>(); |
| 35 | + ids.add("a"); |
| 36 | + ids.add("b"); |
| 37 | + assert helloService.test01(ids).equals("a,b"); |
| 38 | + } |
| 39 | + |
| 40 | + @Test |
| 41 | + public void test02() throws IOException { |
| 42 | + UploadedFile file = new UploadedFile(MimeType.TEXT_PLAIN_VALUE, |
| 43 | + new ByteArrayInputStream("hello".getBytes()), |
| 44 | + "demo1.txt"); |
| 45 | + |
| 46 | + assert helloService.test02(file).equals("demo1.txt"); |
| 47 | + } |
| 48 | + |
| 49 | + @Test |
| 50 | + public void test03() throws IOException { |
| 51 | + assert helloService.test03().equals("test03"); |
| 52 | + } |
| 53 | + |
| 54 | + @Test |
| 55 | + public void test04() throws IOException { |
| 56 | + assert helloService.test04("test04").equals("test04"); |
| 57 | + } |
| 58 | + |
| 59 | + @Test |
| 60 | + public void test05() throws IOException { |
| 61 | + assert helloService.test05(1, "test05").equals("1:\"test05\""); |
| 62 | + } |
| 63 | +} |
0 commit comments