-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6fb0507
commit e4acd20
Showing
9 changed files
with
191 additions
and
3 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
ballerina-tests/http-advanced-tests/tests/http_default_listener_test.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,55 @@ | ||
// Copyright (c) 2025 WSO2 LLC. (http://www.wso2.org). | ||
// | ||
// WSO2 LLC. 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/http; | ||
import ballerina/http_test_common.service1 as _; | ||
import ballerina/http_test_common.service2 as _; | ||
import ballerina/test; | ||
|
||
listener http:Listener defaultListener = http:getDefaultListener(); | ||
|
||
service /api/v3 on defaultListener { | ||
|
||
resource function get greeting() returns string { | ||
return "Hello, World from service 3!"; | ||
} | ||
} | ||
|
||
service /api/v4 on defaultListener { | ||
|
||
resource function get greeting() returns string { | ||
return "Hello, World from service 4!"; | ||
} | ||
} | ||
|
||
listener http:Listener defaultListenerNew = http:getDefaultListener(); | ||
|
||
service /api/v5 on defaultListenerNew { | ||
|
||
resource function get greeting() returns string { | ||
return "Hello, World from service 5!"; | ||
} | ||
} | ||
|
||
final http:Client defaultListenerClient = check new(string `localhost:${http:defaultListenerPort}/api`); | ||
|
||
@test:Config {} | ||
function testDefaultListener() returns error? { | ||
foreach int i in 1...5 { | ||
string response = check defaultListenerClient->/[string `v${i}`]/greeting; | ||
test:assertEquals(response, string `Hello, World from service ${i}!`); | ||
} | ||
} |
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
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
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
64 changes: 64 additions & 0 deletions
64
ballerina-tests/http-security-tests/tests/http_default_listener_test.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,64 @@ | ||
// Copyright (c) 2025 WSO2 LLC. (http://www.wso2.org). | ||
// | ||
// WSO2 LLC. 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/http; | ||
import ballerina/http_test_common as common; | ||
import ballerina/http_test_common.service1 as _; | ||
import ballerina/http_test_common.service2 as _; | ||
import ballerina/test; | ||
|
||
listener http:Listener defaultListener = http:getDefaultListener(); | ||
|
||
service /api/v3 on defaultListener { | ||
|
||
resource function get greeting() returns string { | ||
return "Hello, World from service 3!"; | ||
} | ||
} | ||
|
||
service /api/v4 on defaultListener { | ||
|
||
resource function get greeting() returns string { | ||
return "Hello, World from service 4!"; | ||
} | ||
} | ||
|
||
listener http:Listener defaultListenerNew = http:getDefaultListener(); | ||
|
||
service /api/v5 on defaultListenerNew { | ||
|
||
resource function get greeting() returns string { | ||
return "Hello, World from service 5!"; | ||
} | ||
} | ||
|
||
final http:Client defaultListenerClient = check new(string `localhost:${http:defaultListenerPort}/api`, | ||
secureSocket = { | ||
cert: { | ||
path: common:TRUSTSTORE_PATH, | ||
password: "ballerina" | ||
} | ||
}, | ||
httpVersion = "1.1" | ||
); | ||
|
||
@test:Config {} | ||
function testDefaultListenerWithConfiguration() returns error? { | ||
foreach int i in 1...5 { | ||
string response = check defaultListenerClient->/[string `v${i}`]/greeting; | ||
test:assertEquals(response, string `Hello, World from service ${i}!`); | ||
} | ||
} |
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,3 @@ | ||
## Module overview | ||
|
||
This module provides a mock HTTP service - service1. |
26 changes: 26 additions & 0 deletions
26
ballerina-tests/http-test-common/modules/service1/service.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,26 @@ | ||
// Copyright (c) 2025 WSO2 LLC. (http://www.wso2.org). | ||
// | ||
// WSO2 LLC. 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/http; | ||
|
||
listener http:Listener defaultListener = http:getDefaultListener(); | ||
|
||
service /api/v1 on defaultListener { | ||
|
||
resource function get greeting() returns string { | ||
return "Hello, World from service 1!"; | ||
} | ||
} |
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,3 @@ | ||
## Module overview | ||
|
||
This module provides a mock HTTP service - service2. |
26 changes: 26 additions & 0 deletions
26
ballerina-tests/http-test-common/modules/service2/service.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,26 @@ | ||
// Copyright (c) 2025 WSO2 LLC. (http://www.wso2.org). | ||
// | ||
// WSO2 LLC. 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/http; | ||
|
||
listener http:Listener defaultListener = http:getDefaultListener(); | ||
|
||
service /api/v2 on defaultListener { | ||
|
||
resource function get greeting() returns string { | ||
return "Hello, World from service 2!"; | ||
} | ||
} |