-
Notifications
You must be signed in to change notification settings - Fork 753
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42709 from gabilang/fix-unescape-identifier
Fix NoSuchFieldError for escaped identifiers during bal test
- Loading branch information
Showing
8 changed files
with
162 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...test/src/test/java/org/ballerinalang/testerina/test/EscapedIdentifiersValidationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://wso2.com). | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.ballerinalang.testerina.test; | ||
|
||
import org.ballerinalang.test.context.BMainInstance; | ||
import org.ballerinalang.test.context.BallerinaTestException; | ||
import org.ballerinalang.testerina.test.utils.AssertionUtils; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
|
||
/** | ||
* Test class containing tests related to escaped identifiers validation. | ||
*/ | ||
public class EscapedIdentifiersValidationTest extends BaseTestCase { | ||
|
||
private BMainInstance balClient; | ||
private String projectPath; | ||
|
||
@BeforeClass | ||
public void setup() throws BallerinaTestException { | ||
balClient = new BMainInstance(balServer); | ||
projectPath = projectBasedTestsPath.toString(); | ||
} | ||
|
||
@Test | ||
public void validateEscapedIdentifiersTest() throws BallerinaTestException, IOException { | ||
String[] args = mergeCoverageArgs(new String[]{"validate-escaped-identifiers"}); | ||
String output = balClient.runMainAndReadStdOut("test", args, | ||
new HashMap<>(), projectPath, true); | ||
AssertionUtils.assertOutput("EscapedIdentifiersValidationTest-validateEscapedIdentifiersTest.txt", | ||
output); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
.../command-outputs/unix/EscapedIdentifiersValidationTest-validateEscapedIdentifiersTest.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Compiling source | ||
intg_tests/validate_escaped_identifiers:0.0.0 | ||
|
||
Running Tests with Coverage | ||
|
||
validate_escaped_identifiers | ||
[pass] test | ||
[pass] test_add | ||
|
||
|
||
2 passing | ||
0 failing | ||
0 skipped | ||
|
||
Test execution time :*****s | ||
|
||
Generating Test Report | ||
validate-escaped-identifiers/target/report/test_results.json |
19 changes: 19 additions & 0 deletions
19
...mmand-outputs/windows/EscapedIdentifiersValidationTest-validateEscapedIdentifiersTest.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Compiling source | ||
intg_tests/validate_escaped_identifiers:0.0.0 | ||
|
||
Running Tests with Coverage | ||
|
||
validate_escaped_identifiers | ||
[pass] test | ||
[pass] test_add | ||
|
||
|
||
2 passing | ||
0 failing | ||
0 skipped | ||
|
||
Test execution time :*****s | ||
|
||
Generating Test Report | ||
validate-escaped-identifiers\target\report\test_results.json | ||
|
4 changes: 4 additions & 0 deletions
4
...n-test/src/test/resources/project-based-tests/validate-escaped-identifiers/Ballerina.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[package] | ||
org = "intg_tests" | ||
name = "validate_escaped_identifiers" | ||
version = "0.0.0" |
40 changes: 40 additions & 0 deletions
40
...gration-test/src/test/resources/project-based-tests/validate-escaped-identifiers/main.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
// | ||
// WSO2 Inc. licenses this file to you under the Apache License, | ||
// Version 2.0 (the "License"); you may not use this file except | ||
// in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
public int int\-a = 10; | ||
|
||
client class Client { | ||
resource function get users\-all(string 'order = "asc") returns json { | ||
return { | ||
"users": [ | ||
{ | ||
"name": "Mitchell", | ||
"age": 30 | ||
}, | ||
{ | ||
"name": "Andrew", | ||
"age": 35 | ||
} | ||
] | ||
}; | ||
} | ||
} | ||
|
||
final Client clientEP = new; | ||
|
||
function add(int a, int b) returns int { | ||
return a + b; | ||
} |
28 changes: 28 additions & 0 deletions
28
...t/src/test/resources/project-based-tests/validate-escaped-identifiers/tests/test_main.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
// | ||
// WSO2 Inc. licenses this file to you under the Apache License, | ||
// Version 2.0 (the "License"); you may not use this file except | ||
// in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
import ballerina/test; | ||
|
||
@test:Config {} | ||
function test_add() { | ||
test:assertEquals(add(1, int\-a), 11); | ||
} | ||
|
||
@test:Config {} | ||
function test() { | ||
json res = clientEP->/users\-all(); | ||
test:assertEquals(res, {"users":[{"name":"Mitchell","age":30},{"name":"Andrew","age":35}]}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters