Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Migrate runtime APIs for Java 21 #2216

Merged
merged 132 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
a49085a
[Automated] Update the native jar versions
MohamedSabthar Oct 21, 2024
81c1cd0
Merge branch 'master' of https://github.com/ballerina-platform/module…
MohamedSabthar Oct 23, 2024
dbe767f
[Automated] Update the native jar versions
MohamedSabthar Oct 23, 2024
68333fb
Add static code analyzer rules
MohamedSabthar Oct 25, 2024
478d7da
Use toJson method from jsondata module
lnash94 Sep 18, 2024
df293a6
Update data.jsondata version
lnash94 Sep 18, 2024
3ad6fdf
Update dependencies for data.jsondata version
lnash94 Sep 19, 2024
bbd63bd
Update Ballerina toml dependency
lnash94 Sep 19, 2024
37d7d03
Update the service data biding with toJson
lnash94 Sep 20, 2024
f289581
Update the service data biding with toJson
lnash94 Sep 20, 2024
117fc78
Fix tests with new parserasType , toJson migration
lnash94 Sep 20, 2024
769e4c6
Update the tests
lnash94 Sep 23, 2024
6041c84
Disable test related to table type
lnash94 Sep 23, 2024
d39b444
Update json data version
lnash94 Sep 23, 2024
f23839e
Fix http2 tests
lnash94 Sep 23, 2024
6b3454b
Add test for new migration
lnash94 Sep 23, 2024
1bbc383
Add tests and fix review suggestions
lnash94 Sep 23, 2024
7be63c2
Resolve conflicts
lnash94 Sep 23, 2024
732c351
Remove unwanted dependencies
lnash94 Sep 23, 2024
979b6d2
Updated the changelog.md
lnash94 Sep 23, 2024
0da6bad
Updated tests
lnash94 Sep 23, 2024
bfa639c
Update tests
lnash94 Oct 10, 2024
ab6cd6e
Update data.json data version
lnash94 Oct 29, 2024
319c21e
Update test case
lnash94 Nov 1, 2024
70dd8c4
[Automated] Update the native jar versions
lnash94 Nov 3, 2024
9d43d48
[Automated] Update the native jar versions
lnash94 Nov 3, 2024
210b030
Disable the cyclic-datatype error negative test
lnash94 Nov 4, 2024
9d415c2
[Automated] Update the native jar versions
lnash94 Nov 4, 2024
656cebf
Disable the projection
lnash94 Nov 4, 2024
17d6304
Disable the map type test case
lnash94 Nov 4, 2024
0e7012b
Revert "Disable the map type test case"
lnash94 Nov 5, 2024
edca1f0
Update scan tool version
MohamedSabthar Nov 5, 2024
00fc467
Fix review suggestions
lnash94 Nov 5, 2024
271e798
Update the description
lnash94 Nov 5, 2024
2aa962f
Rename serviceContractType to serviceType
MohamedSabthar Nov 6, 2024
4153e6f
Update native/src/main/java/io/ballerina/stdlib/http/api/HttpConstant…
lnash94 Nov 6, 2024
d375c3b
Merge pull request #2204 from lnash94/integrate-data.json-2
lnash94 Nov 6, 2024
fbacef6
Add logic to remoe file path prefix when normalizing json
MohamedSabthar Nov 6, 2024
57deb16
Refactor java code
MohamedSabthar Nov 6, 2024
70687b9
Update bal path for windows
MohamedSabthar Nov 6, 2024
2007492
Update changelog
MohamedSabthar Nov 6, 2024
e93b453
Merge branch 'master' into static-code
MohamedSabthar Nov 6, 2024
7c05478
Update Ballerina.toml
lnash94 Nov 6, 2024
b5fba51
Merge pull request #2206 from lnash94/lnash94-patch-1
lnash94 Nov 6, 2024
3696696
Update accesslog_enabled test results on Thu Nov 7 02:02:48 UTC 2024
Nov 7, 2024
77bb617
Update h1_h1_passthrough test results on Thu Nov 7 02:02:48 UTC 2024
Nov 7, 2024
d996167
Update h1_transformation test results on Thu Nov 7 02:02:48 UTC 2024
Nov 7, 2024
a077bf2
Update h1c_h1c_passthrough test results on Thu Nov 7 02:02:48 UTC 2024
Nov 7, 2024
c762009
Update h1c_transformation test results on Thu Nov 7 02:02:48 UTC 2024
Nov 7, 2024
5e0a757
Update h2_h1c_passthrough test results on Thu Nov 7 02:02:48 UTC 2024
Nov 7, 2024
42172d0
Update interceptors_passthrough test results on Thu Nov 7 02:02:49 U…
Nov 7, 2024
88d583c
Update observability_enabled test results on Thu Nov 7 02:02:49 UTC …
Nov 7, 2024
5cc12dd
Update snowpeak_passthrough test results on Thu Nov 7 02:02:49 UTC 2024
Nov 7, 2024
7e23cf4
Merge pull request #2207 from ballerina-platform/load-test-results
ballerina-bot Nov 7, 2024
2575b37
Update accesslog_enabled test results on Fri Nov 8 02:02:39 UTC 2024
Nov 8, 2024
228be09
Update h1_h1_passthrough test results on Fri Nov 8 02:02:39 UTC 2024
Nov 8, 2024
857fdbd
Update h1_transformation test results on Fri Nov 8 02:02:39 UTC 2024
Nov 8, 2024
6b44463
Update h1c_h1c_passthrough test results on Fri Nov 8 02:02:39 UTC 2024
Nov 8, 2024
73a955b
Update h1c_transformation test results on Fri Nov 8 02:02:39 UTC 2024
Nov 8, 2024
39f844a
Update h2_h1c_passthrough test results on Fri Nov 8 02:02:39 UTC 2024
Nov 8, 2024
335d0dd
Update interceptors_passthrough test results on Fri Nov 8 02:02:40 U…
Nov 8, 2024
effc239
Update observability_enabled test results on Fri Nov 8 02:02:40 UTC …
Nov 8, 2024
fef631e
Update snowpeak_passthrough test results on Fri Nov 8 02:02:40 UTC 2024
Nov 8, 2024
389fa20
Merge pull request #2208 from ballerina-platform/load-test-results
ballerina-bot Nov 8, 2024
cdfa444
Rename variables in java code
MohamedSabthar Nov 8, 2024
4aa2ac8
Fix static code test hanging in windows
MohamedSabthar Nov 8, 2024
430c2a5
Merge branch 'master' into static-code
MohamedSabthar Nov 8, 2024
f016816
Update accesslog_enabled test results on Sat Nov 9 02:02:56 UTC 2024
Nov 9, 2024
ddc884b
Update h1_h1_passthrough test results on Sat Nov 9 02:02:56 UTC 2024
Nov 9, 2024
08cdd36
Update h1_transformation test results on Sat Nov 9 02:02:56 UTC 2024
Nov 9, 2024
156303a
Update h1c_h1c_passthrough test results on Sat Nov 9 02:02:56 UTC 2024
Nov 9, 2024
5cd081b
Update h1c_transformation test results on Sat Nov 9 02:02:56 UTC 2024
Nov 9, 2024
8e94ea8
Update h2_h1c_passthrough test results on Sat Nov 9 02:02:56 UTC 2024
Nov 9, 2024
66dde97
Update interceptors_passthrough test results on Sat Nov 9 02:02:56 U…
Nov 9, 2024
85294d5
Update observability_enabled test results on Sat Nov 9 02:02:56 UTC …
Nov 9, 2024
a023025
Update snowpeak_passthrough test results on Sat Nov 9 02:02:57 UTC 2024
Nov 9, 2024
26d7104
Merge pull request #2209 from ballerina-platform/load-test-results
ballerina-bot Nov 9, 2024
2e7ffca
Update accesslog_enabled test results on Sun Nov 10 02:04:51 UTC 2024
Nov 10, 2024
d15b8b9
Update h1_h1_passthrough test results on Sun Nov 10 02:04:51 UTC 2024
Nov 10, 2024
0bd3e91
Update h1_transformation test results on Sun Nov 10 02:04:51 UTC 2024
Nov 10, 2024
640f0f2
Update h1c_h1c_passthrough test results on Sun Nov 10 02:04:51 UTC 2024
Nov 10, 2024
a6be1a1
Update h1c_transformation test results on Sun Nov 10 02:04:51 UTC 2024
Nov 10, 2024
18e568e
Update h2_h1c_passthrough test results on Sun Nov 10 02:04:51 UTC 2024
Nov 10, 2024
8504b46
Update interceptors_passthrough test results on Sun Nov 10 02:04:51 U…
Nov 10, 2024
5f9e843
Update observability_enabled test results on Sun Nov 10 02:04:51 UTC …
Nov 10, 2024
b7b6e57
Update snowpeak_passthrough test results on Sun Nov 10 02:04:51 UTC 2024
Nov 10, 2024
39ae164
Merge pull request #2210 from ballerina-platform/load-test-results
ballerina-bot Nov 10, 2024
716349d
Update accesslog_enabled test results on Mon Nov 11 02:01:42 UTC 2024
Nov 11, 2024
099eb4b
Update h1_h1_passthrough test results on Mon Nov 11 02:01:42 UTC 2024
Nov 11, 2024
622defd
Update h1_transformation test results on Mon Nov 11 02:01:42 UTC 2024
Nov 11, 2024
c1d4724
Update h1c_h1c_passthrough test results on Mon Nov 11 02:01:42 UTC 2024
Nov 11, 2024
a3adbc8
Update h1c_transformation test results on Mon Nov 11 02:01:43 UTC 2024
Nov 11, 2024
2657ec2
Update h2_h1c_passthrough test results on Mon Nov 11 02:01:43 UTC 2024
Nov 11, 2024
e331cc2
Update interceptors_passthrough test results on Mon Nov 11 02:01:43 U…
Nov 11, 2024
9136a34
Update observability_enabled test results on Mon Nov 11 02:01:43 UTC …
Nov 11, 2024
290817f
Update snowpeak_passthrough test results on Mon Nov 11 02:01:43 UTC 2024
Nov 11, 2024
ab6b147
Merge pull request #2211 from ballerina-platform/load-test-results
ballerina-bot Nov 11, 2024
f34e33c
Merge branch 'master' into static-code
TharmiganK Nov 11, 2024
09cc30f
Merge pull request #2202 from MohamedSabthar/static-code
TharmiganK Nov 11, 2024
a0d62e2
Update accesslog_enabled test results on Tue Nov 12 02:02:13 UTC 2024
Nov 12, 2024
b845a4a
Update h1_h1_passthrough test results on Tue Nov 12 02:02:13 UTC 2024
Nov 12, 2024
b8651dd
Update h1_transformation test results on Tue Nov 12 02:02:13 UTC 2024
Nov 12, 2024
7daf26a
Update h1c_h1c_passthrough test results on Tue Nov 12 02:02:13 UTC 2024
Nov 12, 2024
18fe1f2
Update h1c_transformation test results on Tue Nov 12 02:02:13 UTC 2024
Nov 12, 2024
bd4c518
Update h2_h1c_passthrough test results on Tue Nov 12 02:02:13 UTC 2024
Nov 12, 2024
f13ac4f
Update interceptors_passthrough test results on Tue Nov 12 02:02:13 U…
Nov 12, 2024
a8e3d5b
Update observability_enabled test results on Tue Nov 12 02:02:13 UTC …
Nov 12, 2024
ef10a2a
Update snowpeak_passthrough test results on Tue Nov 12 02:02:13 UTC 2024
Nov 12, 2024
25400eb
Merge pull request #2212 from ballerina-platform/load-test-results
ballerina-bot Nov 12, 2024
6d760c8
Update accesslog_enabled test results on Wed Nov 13 02:05:21 UTC 2024
Nov 13, 2024
334472d
Update h1_h1_passthrough test results on Wed Nov 13 02:05:21 UTC 2024
Nov 13, 2024
8f47051
Update h1_transformation test results on Wed Nov 13 02:05:21 UTC 2024
Nov 13, 2024
ba09b40
Update h1c_h1c_passthrough test results on Wed Nov 13 02:05:22 UTC 2024
Nov 13, 2024
2c193fc
Update h1c_transformation test results on Wed Nov 13 02:05:22 UTC 2024
Nov 13, 2024
2de72da
Update h2_h1c_passthrough test results on Wed Nov 13 02:05:22 UTC 2024
Nov 13, 2024
5877cb1
Update interceptors_passthrough test results on Wed Nov 13 02:05:22 U…
Nov 13, 2024
88bae5e
Update observability_enabled test results on Wed Nov 13 02:05:22 UTC …
Nov 13, 2024
70a2126
Update snowpeak_passthrough test results on Wed Nov 13 02:05:22 UTC 2024
Nov 13, 2024
94229df
Merge pull request #2214 from ballerina-platform/load-test-results
ballerina-bot Nov 13, 2024
0632800
[Automated] Update the native jar versions
TharmiganK Nov 13, 2024
41e43d4
[Automated] Update the native jar versions
TharmiganK Nov 13, 2024
9268a31
Update netty version
TharmiganK Nov 13, 2024
8e14db3
Update changelog
TharmiganK Nov 13, 2024
3feb04b
Merge pull request #2215 from ballerina-platform/update-netty-version
TharmiganK Nov 13, 2024
6f660e7
Fix merge conflicts
HindujaB Nov 13, 2024
24c0aee
Migrate runtime APIs and fix compilation
HindujaB Nov 13, 2024
57387f2
Update json data version
HindujaB Nov 14, 2024
93ba8b8
[Automated] Update the native jar versions
HindujaB Nov 14, 2024
ab973fa
[Automated] Update the native jar versions
HindujaB Nov 14, 2024
de77bf9
Disable jsondata tests
HindujaB Nov 14, 2024
5aa7f7c
Revert "[Automated] Update the native jar versions"
HindujaB Nov 14, 2024
e5f8d8c
Revert "[Automated] Update the native jar versions"
HindujaB Nov 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ load-tests/**/Dependencies.toml
# Ballerina related ignores
Ballerina.lock
velocity.log*

compiler-plugin-tests/**/target
15 changes: 15 additions & 0 deletions ballerina-tests/http-client-tests/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ dependencies = [
{org = "ballerina", name = "time"}
]

[[package]]
org = "ballerina"
name = "data.jsondata"
version = "0.3.0"
scope = "testOnly"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.object"}
]
modules = [
{org = "ballerina", packageName = "data.jsondata", moduleName = "data.jsondata"}
]

[[package]]
org = "ballerina"
name = "file"
Expand All @@ -75,6 +88,7 @@ dependencies = [
{org = "ballerina", name = "cache"},
{org = "ballerina", name = "constraint"},
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "data.jsondata"},
{org = "ballerina", name = "file"},
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
Expand Down Expand Up @@ -104,6 +118,7 @@ name = "http_client_tests"
version = "2.13.0"
dependencies = [
{org = "ballerina", name = "constraint"},
{org = "ballerina", name = "data.jsondata"},
{org = "ballerina", name = "http"},
{org = "ballerina", name = "http_test_common"},
{org = "ballerina", name = "io"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/http;
import ballerina/mime;
import ballerina/test;
import ballerina/data.jsondata;

service /api on new http:Listener(resBindingAdvancedPort) {

Expand All @@ -41,6 +43,31 @@ service /api on new http:Listener(resBindingAdvancedPort) {
resource function get byteArray() returns byte[] {
return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
}

resource function get overwriteNames/jsont(boolean y) returns json|TPerson {
if y {
return {"name": "John", "age": "23"};
}
TPerson t = {firstName: "Potter", personAge: "30"};
return t;
}

resource function post overwriteNames/jsont(TPerson payload) returns TPerson {
return payload;
}

resource function get status/code() returns OKPerson {
return {body: {firstName: "Potter", personAge: "40"}};
}

resource function get projection/tests() returns json {
json v = {
a: "a",
b: "b",
c: "c"
};
return v;
}
}

final http:Client clientEP = check new (string `localhost:${resBindingAdvancedPort}/api`);
Expand Down Expand Up @@ -101,3 +128,52 @@ function testResponseWithAnydataResBinding() returns error? {
test:assertFail("Invalid response type");
}
}

public type TPerson record {
@jsondata:Name {
value: "name"
}
string firstName;
@jsondata:Name {
value: "age"
}
string personAge;
};

public type OKPerson record {|
*http:Ok;
TPerson body;
|};

@test:Config {}
function clientoverwriteResponseJsonName() returns error? {
TPerson res1 = check clientEP->/overwriteNames/jsont(y = true);
test:assertEquals(res1, {firstName: "John", personAge: "23"});

json res2 = check clientEP->/overwriteNames/jsont(y = false);
test:assertEquals(res2, {"name": "Potter", "age": "30"});

json j = {
name: "Sumudu",
age: "29"
};

TPerson res3 = check clientEP->/overwriteNames/jsont.post(j);
test:assertEquals(res3, {firstName: "Sumudu", personAge: "29"});

json res4 = check clientEP->/status/code;
test:assertEquals(res4, {name: "Potter", age: "40"});
}

public type AB record {|
string a;
string b;
|};

@test:Config {}
function projectionTestWithClient() {
AB|error res = clientEP->/projection/tests();
if res is error {
test:assertEquals(res.message(), "Payload binding failed: undefined field 'c'");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -616,9 +616,9 @@ function testAllBindingErrorsWithNillableTypes() returns error? {
test:assertEquals(response.statusCode, 200, msg = "Found unexpected output");
common:assertHeaderValue(check response.getHeader(common:CONTENT_TYPE), common:TEXT_PLAIN);
common:assertTextPayload(response.getTextPayload(),
"Payload binding failed: 'map<json>' value cannot be converted to " +
"'xml<(lang.xml:Element|lang.xml:Comment|lang.xml:ProcessingInstruction|lang.xml:Text)>?'|" +
"incompatible typedesc int? found for 'text/plain' mime type");
"Payload binding failed: incompatible expected type 'xml<(lang.xml:Element|lang.xml:Comment|" +
"lang.xml:ProcessingInstruction|lang.xml:Text)>?' for value " +
"'{\"id\":\"chamil\",\"values\":{\"a\":2,\"b\":45,\"c\":{\"x\":\"mnb\",\"y\":\"uio\"}}}'|incompatible typedesc int? found for 'text/plain' mime type");
} else {
test:assertFail(msg = "Found unexpected output type: " + response.message());
}
Expand Down Expand Up @@ -815,9 +815,7 @@ function testDBRecordErrorNegative() {
ClientDBErrorPerson|error response = clientDBBackendClient->post("/backend/getRecord", "want record");
if (response is error) {
common:assertTrueTextPayload(response.message(),
"Payload binding failed: 'map<json>' value cannot be converted to 'http_client_tests:ClientDBErrorPerson'");
common:assertTrueTextPayload(response.message(),
"missing required field 'weight' of type 'float' in record 'http_client_tests:ClientDBErrorPerson'");
"Payload binding failed: required field 'weight' not present in JSON");
} else {
test:assertFail(msg = "Found unexpected output type: ClientDBErrorPerson");
}
Expand All @@ -828,7 +826,7 @@ function testDBRecordArrayNegative() {
ClientDBErrorPerson[]|error response = clientDBBackendClient->post("/backend/getRecordArr", "want record arr");
if (response is error) {
common:assertTrueTextPayload(response.message(),
"Payload binding failed: 'json[]' value cannot be converted to 'http_client_tests:ClientDBErrorPerson[]'");
"Payload binding failed: required field 'weight' not present in JSON");
} else {
test:assertFail(msg = "Found unexpected output type: ClientDBErrorPerson[]");
}
Expand All @@ -852,7 +850,7 @@ function testMapOfStringDataBindingWithJsonPayload() {
map<string>|error response = clientDBBackendClient->get("/backend/getJson");
if (response is error) {
common:assertTrueTextPayload(response.message(),
"Payload binding failed: 'map<json>' value cannot be converted to 'map<string>'");
"Payload binding failed: incompatible expected type 'string' for value '{\"a\":2,\"b\":45,\"c\":{\"x\":\"mnb\",\"y\":\"uio\"}}'");
} else {
test:assertFail(msg = "Found unexpected output type: map<string>");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ function testIntMapDatabindingByType() returns error? {
test:assertEquals(response, {"name": 11, "team": 22}, msg = "Found unexpected output");
}

@test:Config {}
@test:Config {enable:false}
function testIntTableDatabinding() returns error? {
table<map<int>> tbl = check clientDBBackendClient->get("/anydataTest/intTableType");
object {
Expand All @@ -355,7 +355,7 @@ function testIntTableDatabinding() returns error? {
}
}

@test:Config {}
@test:Config {enable:false}
function testIntTableOrMapofIntArrayDatabinding() returns error? {
map<int>[]|table<map<int>> response = check clientDBBackendClient->get("/anydataTest/intTableType");
if response is map<int>[] {
Expand All @@ -369,7 +369,7 @@ function testIntTableOrMapofIntArrayDatabinding() returns error? {
}
}

@test:Config {}
@test:Config {enable:false}
function testIntTableOrXmlArrayDatabinding() returns error? {
table<map<int>>|xml tbl = check clientDBBackendClient->get("/anydataTest/intTableType");
if tbl is table<map<int>> {
Expand All @@ -387,7 +387,7 @@ function testIntTableOrXmlArrayDatabinding() returns error? {
}
}

@test:Config {}
@test:Config {enable:false}
function testIntTableDatabindingByType() returns error? {
table<map<int>> tbl = check clientDBBackendClient->get("/anydataTest/intTableTypeWithInvalidMimeType");
object {
Expand Down Expand Up @@ -448,7 +448,7 @@ function testStringMapDatabindingByType() returns error? {
test:assertEquals(response, {name: "hello", team: "ballerina"}, msg = "Found unexpected output");
}

@test:Config {}
@test:Config {enable:false}
function testStringTableDatabinding() returns error? {
table<map<string>> tbl = check clientDBBackendClient->get("/anydataTest/stringTableType");
object {
Expand All @@ -462,7 +462,7 @@ function testStringTableDatabinding() returns error? {
}
}

@test:Config {}
@test:Config {enable:false}
function testStringTableDatabindingByType() returns error? {
table<map<string>> tbl = check clientDBBackendClient->get("/anydataTest/stringTableTypeWithInvalidMimeType");
object {
Expand Down Expand Up @@ -508,7 +508,7 @@ function testRecordMapDatabindingByType() returns error? {
test:assertEquals(response.get("1"), {name: "hello", age: 23}, msg = "Found unexpected output");
}

@test:Config {}
@test:Config {enable:false}
function testRecordTableDatabinding() returns error? {
table<ClientAnydataDBPerson> tbl = check clientDBBackendClient->get("/anydataTest/recordTableType");
object {
Expand All @@ -522,7 +522,7 @@ function testRecordTableDatabinding() returns error? {
}
}

@test:Config {}
@test:Config {enable: false}
function testRecordTableDatabindingByType() returns error? {
table<ClientAnydataDBPerson> tbl = check clientDBBackendClient->get("/anydataTest/recordTableTypeWithInvalidMimeType");
object {
Expand Down Expand Up @@ -574,7 +574,7 @@ function testByteArrMapDatabindingByType() returns error? {
test:assertEquals(check strings:fromBytes(val), "STDLIB", msg = "Found unexpected output");
}

@test:Config {}
@test:Config {enable: false}
function testByteArrTableDatabinding() returns error? {
table<map<byte[]>> response = check clientDBBackendClient->get("/anydataTest/byteArrTableType");
object {
Expand All @@ -589,7 +589,7 @@ function testByteArrTableDatabinding() returns error? {
}
}

@test:Config {}
@test:Config {enable:false}
function testByteArrTableDatabindingByType() returns error? {
table<map<byte[]>> response = check clientDBBackendClient->get("/anydataTest/byteArrTableTypeWithInvalidMimeType");
object {
Expand All @@ -609,7 +609,7 @@ function testXmlArrDatabinding() {
xml[]|error response = clientDBBackendClient->get("/anydataTest/xmlArrType");
if response is error {
common:assertTrueTextPayload(response.message(),
"Payload binding failed: 'json[]' value cannot be converted to 'xml<");
"Payload binding failed: invalid type 'xml<(lang.xml:Element|lang.xml:Comment|lang.xml:ProcessingInstruction|lang.xml:Text)>' expected 'anydata'");
} else {
test:assertEquals(response[0], xml `<name>WSO2</name>`, msg = "Found unexpected output");
}
Expand All @@ -620,7 +620,7 @@ function testXmlArrDatabindingByType() {
xml[]|error response = clientDBBackendClient->get("/anydataTest/xmlArrTypeWithInvalidMimeType");
if response is error {
common:assertTrueTextPayload(response.message(),
"Payload binding failed: 'json[]' value cannot be converted to 'xml");
"Payload binding failed: invalid type 'xml<(lang.xml:Element|lang.xml:Comment|lang.xml:ProcessingInstruction|lang.xml:Text)>' expected 'anydata'");
} else {
test:assertEquals(response[0], xml `<name>WSO2</name>`, msg = "Found unexpected output");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ service /api on new http:Listener(statusCodeBindingPort2) {
headers: {userId: "user-1", reqId: 1}
};
}

resource function get album/auther() returns OKPerson {
return {body: {firstName: "Potter", personAge: "40"}};
}
}

final http:StatusCodeClient albumClient = check new (string `localhost:${statusCodeBindingPort2}/api`);
Expand Down Expand Up @@ -467,8 +471,8 @@ function testUnionPayloadBindingWithStatusCodeResponse() returns error? {
AlbumFoundInvalid|AlbumFound|AlbumNotFound|error res5 = albumClient->/albums/'1;
if res5 is error {
test:assertTrue(res5 is http:PayloadBindingError);
test:assertTrue(res5.message().includes("Payload binding failed: 'map<json>' value cannot be" +
" converted to 'http_client_tests:AlbumInvalid"), "Invalid error message");
test:assertTrue(res5.message().includes("Payload binding failed: required field 'invalidField' not present in JSON"),
"Invalid error message");
} else {
test:assertFail("Invalid response type");
}
Expand Down Expand Up @@ -670,3 +674,9 @@ function testStatusCodeBindingWithNamedHeaders() returns error? {
test:assertFail("Invalid response type");
}
}

@test:Config {}
function testOverwriteName() returns error? {
OKPerson res = check albumClient->/album/auther;
test:assertEquals(res.body, {firstName: "Potter", personAge: "40"});
}
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,7 @@ function testDataBindingStructWithNoMatchingContent() returns error? {
http:Response|error response = dataBindingClient->post("/dataBinding/body6", req);
if response is http:Response {
test:assertEquals(response.statusCode, 400, msg = "Found unexpected output");
check common:assertJsonErrorPayloadPartialMessage(check response.getJsonPayload(), "data binding failed: {ballerina");
check common:assertJsonErrorPayloadPartialMessage(check response.getJsonPayload(), "}ConversionError, {\"message\":\"'map<json>' ");
check common:assertJsonErrorPayloadPartialMessage(check response.getJsonPayload(), "value cannot be converted to 'http_dispatching_tests:Person':");
check common:assertJsonErrorPayloadPartialMessage(check response.getJsonPayload(), "missing required field 'age' of type 'int' in record 'http_dispatching_tests:Person'");
check common:assertJsonErrorPayloadPartialMessage(check response.getJsonPayload(), "field 'team' cannot be added to the closed record 'http_dispatching_tests:Person'\"");
check common:assertJsonErrorPayloadPartialMessage(check response.getJsonPayload(), "data binding failed: undefined field 'team'");
} else {
test:assertFail(msg = "Found unexpected output type: " + response.message());
}
Expand All @@ -411,11 +407,7 @@ function testDataBindingStructWithInvalidTypes() returns error? {
http:Response|error response = dataBindingClient->post("/dataBinding/body7", req);
if response is http:Response {
test:assertEquals(response.statusCode, 400, msg = "Found unexpected output");
check common:assertJsonErrorPayloadPartialMessage(check response.getJsonPayload(), "'map<json>' value cannot be converted to 'http_dispatching_tests:Stock'");
check common:assertJsonErrorPayloadPartialMessage(check response.getJsonPayload(), "missing required field 'price' of type 'float' in record 'http_dispatching_tests:Stock'");
check common:assertJsonErrorPayloadPartialMessage(check response.getJsonPayload(), "missing required field 'id' of type 'int' in record 'http_dispatching_tests:Stock'");
check common:assertJsonErrorPayloadPartialMessage(check response.getJsonPayload(), "field 'name' cannot be added to the closed record 'http_dispatching_tests:Stock'");
check common:assertJsonErrorPayloadPartialMessage(check response.getJsonPayload(), "field 'team' cannot be added to the closed record 'http_dispatching_tests:Stock'");
check common:assertJsonErrorPayloadPartialMessage(check response.getJsonPayload(), "data binding failed: undefined field 'name'");
} else {
test:assertFail(msg = "Found unexpected output type: " + response.message());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ public function testSendingMap() returns error? {
common:assertJsonPayload(resp.getJsonPayload(), {sam: 50, jhon: 60});
}

@test:Config {}
@test:Config {
enable: false
}
public function testSendingMapArray() returns error? {
map<json> jj = {sam: {hello: "world"}, jhon: {no: 56}};
map<json>[] val = [jj, jj];
Expand All @@ -102,7 +104,9 @@ public function testSendingTable() returns error? {
]);
}

@test:Config {}
@test:Config {
enable: false
}
public function testSendingTableArray() returns error? {
CustomerTable customerTab = table [
{id: 13, fname: "Dan", lname: "Bing"}
Expand Down Expand Up @@ -236,7 +240,7 @@ public function testSendingClosedRecordTable() returns error? {
]);
}

@test:Config {}
@test:Config { enable: false}
public function testRequestAnydataNegative() returns error? {
json[] x = [];
x.push(x);
Expand Down Expand Up @@ -472,7 +476,7 @@ public function testGettingClosedRecordArray() returns error? {
]);
}

@test:Config {}
@test:Config {enable: false}
public function testResponseAnydataNegative() returns error? {
http:Response resp = check outRequestClient->get("/mytest/anydataNegative");
test:assertEquals(resp.statusCode, 500, msg = "Found unexpected output");
Expand Down
Loading
Loading