|
14 | 14 | // specific language governing permissions and limitations |
15 | 15 | // under the License. |
16 | 16 |
|
17 | | -import ballerina/http; |
18 | | -import ballerina/io; |
19 | | -import ballerina/log; |
20 | | - |
21 | | -final string artifactPath = string `${ballerinaTestDir}${sep}generated_artifacts`; |
22 | | - |
23 | | -service / on new http:Listener(8080) { |
24 | | - ServiceSchema[] artifacts = []; |
25 | | - final string artifactJsonFilename = string `${artifactPath}${sep}artifacts_0.json`; |
26 | | - |
27 | | - function init() returns error? { |
28 | | - log:printInfo("Starting the test server on port 8080"); |
29 | | - } |
30 | | - |
31 | | - resource function post services(http:Request req) returns Service|http:InternalServerError|error { |
32 | | - return getSchemaAndReturnResponse(req, self.artifactJsonFilename, self.artifacts); |
33 | | - } |
34 | | -} |
35 | | - |
36 | | -service / on new http:Listener(8081) { |
37 | | - ServiceSchema[] artifacts = []; |
38 | | - final string artifactJsonFilename = string `${artifactPath}${sep}artifacts_1.json`; |
39 | | - |
40 | | - function init() returns error? { |
41 | | - log:printInfo("Starting the test server on port 8081"); |
42 | | - } |
43 | | - |
44 | | - resource function post services(http:Request req) returns Service|http:InternalServerError|error { |
45 | | - return getSchemaAndReturnResponse(req, self.artifactJsonFilename, self.artifacts); |
46 | | - } |
47 | | -} |
48 | | - |
49 | | -service / on new http:Listener(8082) { |
50 | | - ServiceSchema[] artifacts = []; |
51 | | - final string artifactJsonFilename = string `${artifactPath}${sep}artifacts_2.json`; |
52 | | - |
53 | | - function init() returns error? { |
54 | | - log:printInfo("Starting the test server on port 8082"); |
55 | | - } |
56 | | - |
57 | | - resource function post services(http:Request req) returns Service|http:InternalServerError|error { |
58 | | - return getSchemaAndReturnResponse(req, self.artifactJsonFilename, self.artifacts); |
59 | | - } |
60 | | -} |
61 | | - |
62 | | -service / on new http:Listener(8083) { |
63 | | - ServiceSchema[] artifacts = []; |
64 | | - final string artifactJsonFilename = string `${artifactPath}${sep}artifacts_3.json`; |
65 | | - |
66 | | - function init() returns error? { |
67 | | - log:printInfo("Starting the test server on port 8083"); |
68 | | - } |
69 | | - |
70 | | - resource function post services(http:Request req) returns Service|http:InternalServerError|error { |
71 | | - return getSchemaAndReturnResponse(req, self.artifactJsonFilename, self.artifacts); |
72 | | - } |
73 | | -} |
74 | | - |
75 | | -service / on new http:Listener(8092) { |
76 | | - ServiceSchema[] artifacts = []; |
77 | | - final string artifactJsonFilename = string `${artifactPath}${sep}artifacts_4.json`; |
78 | | - |
79 | | - function init() returns error? { |
80 | | - log:printInfo("Starting the test server on port 8092"); |
81 | | - } |
82 | | - |
83 | | - resource function post services(http:Request req) returns Service|http:InternalServerError|error { |
84 | | - return getSchemaAndReturnResponse(req, self.artifactJsonFilename, self.artifacts); |
85 | | - } |
86 | | -} |
87 | | - |
88 | | -service / on new http:Listener(8085) { |
89 | | - ServiceSchema[] artifacts = []; |
90 | | - final string artifactJsonFilename = string `${artifactPath}${sep}artifacts_5.json`; |
91 | | - |
92 | | - function init() returns error? { |
93 | | - log:printInfo("Starting the test server on port 8085"); |
94 | | - } |
95 | | - |
96 | | - resource function post services(http:Request req) returns Service|http:InternalServerError|error { |
97 | | - return getSchemaAndReturnResponse(req, self.artifactJsonFilename, self.artifacts); |
98 | | - } |
99 | | -} |
100 | | - |
101 | | -service / on new http:Listener(8086) { |
102 | | - ServiceSchema[] artifacts = []; |
103 | | - final string artifactJsonFilename = string `${artifactPath}${sep}artifacts_6.json`; |
104 | | - |
105 | | - function init() returns error? { |
106 | | - log:printInfo("Starting the test server on port 8086"); |
107 | | - } |
108 | | - |
109 | | - resource function post services(http:Request req) returns Service|http:InternalServerError|error { |
110 | | - return getSchemaAndReturnResponse(req, self.artifactJsonFilename, self.artifacts); |
111 | | - } |
112 | | -} |
113 | | - |
114 | | -service / on new http:Listener(8087) { |
115 | | - ServiceSchema[] artifacts = []; |
116 | | - final string artifactJsonFilename = string `${artifactPath}${sep}artifacts_7.json`; |
117 | | - |
118 | | - function init() returns error? { |
119 | | - log:printInfo("Starting the test server on port 8087"); |
120 | | - } |
121 | | - |
122 | | - resource function post services(http:Request req) returns Service|http:InternalServerError|error { |
123 | | - return getSchemaAndReturnResponse(req, self.artifactJsonFilename, self.artifacts); |
124 | | - } |
125 | | -} |
126 | | - |
127 | | -service / on new http:Listener(8088) { |
128 | | - ServiceSchema[] artifacts = []; |
129 | | - final string artifactJsonFilename = string `${artifactPath}${sep}artifacts_8.json`; |
130 | | - |
131 | | - function init() returns error? { |
132 | | - log:printInfo("Starting the test server on port 8088"); |
133 | | - } |
134 | | - |
135 | | - resource function post services(http:Request req) returns Service|http:InternalServerError|error { |
136 | | - return getSchemaAndReturnResponse(req, self.artifactJsonFilename, self.artifacts); |
137 | | - } |
138 | | -} |
139 | | - |
140 | | -service / on new http:Listener(8091) { |
141 | | - ServiceSchema[] artifacts = []; |
142 | | - final string artifactJsonFilename = string `${artifactPath}${sep}artifacts_11.json`; |
143 | | - |
144 | | - function init() returns error? { |
145 | | - log:printInfo("Starting the test server on port 8091"); |
146 | | - } |
147 | | - |
148 | | - resource function post services(http:Request req) returns Service|http:Unauthorized|error { |
149 | | - ServiceSchema schema = check traverseMultiPartRequest(req); |
150 | | - self.artifacts.push(schema); |
151 | | - check io:fileWriteJson(self.artifactJsonFilename, self.artifacts.toJson()); |
152 | | - return {body: {message: "Unauthorized"}}; |
153 | | - } |
154 | | -} |
155 | | - |
156 | | -function getSchemaAndReturnResponse(http:Request req, |
157 | | - string artifactJsonFilename, ServiceSchema[] artifacts) returns http:InternalServerError|error { |
158 | | - ServiceSchema schema = check traverseMultiPartRequest(req); |
159 | | - artifacts.push(schema); |
160 | | - check io:fileWriteJson(artifactJsonFilename, artifacts.toJson()); |
161 | | - return returnDummyResponse(); |
162 | | -} |
| 17 | +// The catalog API mock server has been moved to ballerina-tests/mock-server/. |
| 18 | +// It runs as a Docker container per test group via @test:BeforeGroups/@test:AfterGroups. |
| 19 | +// See test_services.bal for the container lifecycle management and |
| 20 | +// test_utils.bal for initializeMockServerContainer()/cleanDockerContainer(). |
0 commit comments