MCPcopy Index your code
hub / github.com/HTTP-RPC/Kilo / Examples

Class Examples

kilo-test/src/test/java/org/httprpc/kilo/examples/Examples.java:38–307  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36import static org.httprpc.kilo.util.Collections.*;
37
38public class Examples {
39 public interface Example {
40 void execute() throws Exception;
41 }
42
43 private static final URI baseURI = URI.create("http://localhost:8080/kilo-test/");
44
45 public static void main(String[] args) {
46 execute("Math Service 1", Examples::mathService1);
47 execute("Math Service 2", Examples::mathService2);
48
49 execute("JSON Encoder", Examples::jsonEncoder);
50 execute("Text Encoder", Examples::textEncoder);
51 execute("CSV Encoder", Examples::csvEncoder);
52
53 execute("Template Encoder", Examples::templateEncoder);
54 execute("Variables", Examples::variables);
55 execute("Repeating Sections", Examples::repeatingSections);
56 execute("Conditional Sections", Examples::conditionalSections);
57 execute("Inverted Sections", Examples::invertedSections);
58 execute("Resources", Examples::resources);
59 execute("Includes", Examples::includes);
60 execute("Comments", Examples::comments);
61
62 execute("Adapt Bean", Examples::adaptBean);
63 execute("Coerce Bean", Examples::coerceBean);
64 execute("Interface Proxy", Examples::interfaceProxy);
65
66 execute("Element Adapter", Examples::elementAdapter);
67
68 execute("Collections", Examples::collections);
69 }
70
71 private static void execute(String label, Example example) {
72 System.out.println(label);
73
74 try {
75 example.execute();
76 } catch (Exception exception) {
77 System.out.println(exception.getMessage());
78 }
79
80 System.out.println();
81 }
82
83 public static void mathService1() throws IOException {
84 // GET /math/sum?a=2&b=4
85 var webServiceProxy = new WebServiceProxy("GET", baseURI.resolve("math/sum"));
86
87 webServiceProxy.setArguments(mapOf(
88 entry("a", 4),
89 entry("b", 2)
90 ));
91
92 System.out.println(webServiceProxy.invoke()); // 6.0
93 }
94
95 public static void mathService2() throws IOException {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected