-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration tests for synapse expressions
Add integration tests for synapse expressions Related to /issues/3749
- Loading branch information
1 parent
7671dd3
commit 8c52729
Showing
6 changed files
with
97 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
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
80 changes: 80 additions & 0 deletions
80
.../src/test/java/org/wso2/carbon/esb/synapse/expression/test/SynapseExpressionTestCase.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,80 @@ | ||
/* | ||
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. | ||
* | ||
* 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. | ||
*/ | ||
package org.wso2.carbon.esb.synapse.expression.test; | ||
|
||
import org.testng.annotations.AfterClass; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
import org.wso2.esb.integration.common.utils.CarbonLogReader; | ||
import org.wso2.esb.integration.common.utils.ESBIntegrationTest; | ||
import org.wso2.esb.integration.common.utils.clients.SimpleHttpClient; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.testng.Assert.assertTrue; | ||
|
||
/** | ||
* Testcase to test Synapse Expressions to fetch registry, registry property, path query and function params | ||
*/ | ||
public class SynapseExpressionTestCase extends ESBIntegrationTest { | ||
|
||
private CarbonLogReader carbonLogReader; | ||
private static final String targetApiName = "synapseexpression_api"; | ||
|
||
@BeforeClass(alwaysRun = true) | ||
public void uploadSynapseConfig() throws Exception { | ||
super.init(); | ||
verifyAPIExistence(targetApiName); | ||
carbonLogReader = new CarbonLogReader(); | ||
carbonLogReader.start(); | ||
} | ||
|
||
@Test(groups = "wso2.esb", description = "Testcase to test Synapse Expressions to fetch registry, registry " + | ||
"property, path query and function params") | ||
public void testSynapseExpressions() throws Exception { | ||
String contentType = "application/json"; | ||
String payload = "{\"hello\": \"world\"}"; | ||
String url = getApiInvocationURL(targetApiName); | ||
url = url + "/abc/hello/pqr?qparam1=zxc&qparam2=uio"; | ||
|
||
Map<String, String> headers = new HashMap<>(1); | ||
headers.put("Content-Type", contentType); | ||
|
||
SimpleHttpClient httpClient = new SimpleHttpClient(); | ||
httpClient.doPost(url, headers, payload, contentType); | ||
|
||
carbonLogReader.checkForLog("pathParam1 = abc, pathParam2 = pqr, queryParam1 = zxc, queryParam2 = uio," + | ||
" regProp = hello world, regValue = John", DEFAULT_TIMEOUT); | ||
String logs = carbonLogReader.getLogs(); | ||
assertTrue(logs.contains("pathParam1 = abc")); | ||
assertTrue(logs.contains("pathParam2 = pqr")); | ||
assertTrue(logs.contains("queryParam1 = zxc")); | ||
assertTrue(logs.contains("queryParam2 = uio")); | ||
assertTrue(logs.contains("regProp = hello world")); | ||
assertTrue(logs.contains("regValue = John")); | ||
assertTrue(logs.contains("funcParam1 = hello")); | ||
assertTrue(logs.contains("funcParam2 = world")); | ||
carbonLogReader.stop(); | ||
} | ||
|
||
@AfterClass(alwaysRun = true) | ||
public void destroy() throws Exception { | ||
super.cleanup(); | ||
} | ||
} |
Binary file added
BIN
+6.15 KB
...ts/ESB/server/repository/deployment/server/carbonapps/SynapseExpressionTestCase_1.0.0.car
Binary file not shown.
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